001/*
002 *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003 *
004 *  This file is licensed to You under the Eclipse Public License (EPL);
005 *  You may not use this file except in compliance with the License. You
006 *  may obtain a copy of the License at
007 *
008 *      http://www.opensource.org/licenses/eclipse-1.0.php
009 *
010 *  See the COPYRIGHT.txt file distributed with this work for information
011 *  regarding copyright ownership.
012 */
013package gnu.java.lang;
014
015import java.lang.instrument.Instrumentation;
016import java.lang.instrument.ClassDefinition;
017
018import org.jikesrvm.classloader.RVMType;
019import org.jikesrvm.classloader.RVMClass;
020import org.jikesrvm.classloader.RVMArray;
021
022
023/**
024 * Jikes RVM implementation of VMInstrumentationImpl
025 */
026final class VMInstrumentationImpl {
027  static boolean isRedefineClassesSupported() {
028    return false;
029  }
030
031  static void redefineClasses(Instrumentation inst,
032    ClassDefinition[] definitions) {
033    throw new UnsupportedOperationException();
034  }
035
036  static Class<?>[] getAllLoadedClasses() {
037    return java.lang.JikesRVMSupport.getAllLoadedClasses();
038  }
039
040  static Class<?>[] getInitiatedClasses(ClassLoader loader) {
041    return java.lang.JikesRVMSupport.getInitiatedClasses(loader);
042  }
043
044  static long getObjectSize(Object objectToSize) {
045    Class<?> cl = objectToSize.getClass();
046    RVMType vmType = java.lang.JikesRVMSupport.getTypeForClass(cl);
047    if (cl.isArray()) {
048      RVMArray vmArray = (RVMArray)vmType;
049      int nelements = java.lang.reflect.Array.getLength(objectToSize);
050      return vmArray.getInstanceSize(nelements);
051    } else {
052      RVMClass vmClass = (RVMClass)vmType;
053      return vmClass.getInstanceSize();
054    }
055  }
056}