/** Get an instance of an object capable of reflectively invoking this method */
 @RuntimePure
 @SuppressWarnings("unchecked")
 public synchronized ReflectionBase getInvoker() {
   if (!VM.runningVM) {
     return null;
   }
   ReflectionBase invoker;
   if (invokeMethods != null) {
     synchronized (RVMMethod.class) {
       invoker = invokeMethods.get(this);
     }
   } else {
     invoker = null;
   }
   if (invoker == null) {
     Class<ReflectionBase> reflectionClass =
         (Class<ReflectionBase>) RVMClass.createReflectionClass(this);
     if (reflectionClass != null) {
       try {
         invoker = reflectionClass.newInstance();
       } catch (Throwable e) {
         throw new Error(e);
       }
     } else {
       invoker = ReflectionBase.nullInvoker;
     }
     if (invokeMethods != null) {
       synchronized (RVMMethod.class) {
         invokeMethods.put(this, invoker);
       }
     }
   }
   return invoker;
 }
 /** Find or create a JTOC offset for this method */
 public final synchronized Offset findOrCreateJtocOffset() {
   if (VM.VerifyAssertions) VM._assert(!isStatic() && !isObjectInitializer());
   Offset jtocOffset = getJtocOffset();
   ;
   if (jtocOffset.EQ(Offset.zero())) {
     jtocOffset = Statics.allocateReferenceSlot(true);
     Statics.setSlotContents(jtocOffset, getCurrentEntryCodeArray());
     synchronized (jtocOffsets) {
       jtocOffsets.put(this, Integer.valueOf(jtocOffset.toInt()));
     }
   }
   return jtocOffset;
 }
 /** Returns the parameter annotations for this method. */
 @Pure
 public final Annotation[][] getDeclaredParameterAnnotations() {
   Annotation[][] result;
   synchronized (declaredParameterAnnotations) {
     result = declaredParameterAnnotations.get(this);
   }
   if (result == null) {
     RVMAnnotation[][] parameterAnnotations = getParameterAnnotations();
     result = new Annotation[parameterAnnotations.length][];
     for (int a = 0; a < result.length; ++a) {
       result[a] = toAnnotations(parameterAnnotations[a]);
     }
     synchronized (declaredParameterAnnotations) {
       declaredParameterAnnotations.put(this, result);
     }
   }
   return result;
 }
Beispiel #4
0
 /**
  * This is the findOrCreate() method through which all Atoms are ultimately created. The
  * constructor for Atom is a private method, so someone has to call one of the public
  * findOrCreate() methods to get a new one. And they all feed through here.
  */
 private static Atom findOrCreate(byte[] bytes, boolean create, String str) {
   Atom val = new Atom(bytes, -1, str);
   val = dictionary.get(val);
   if (val != null || !create) return val;
   synchronized (Atom.class) {
     val = new Atom(bytes, nextId++, str);
     int column = val.id >> LOG_ROW_SIZE;
     if (column == atoms.length) {
       Atom[][] tmp = new Atom[column + 1][];
       for (int i = 0; i < column; i++) {
         tmp[i] = atoms[i];
       }
       atoms = tmp;
       atoms[column] = new Atom[1 << LOG_ROW_SIZE];
     }
     atoms[column][val.id & ROW_MASK] = val;
     dictionary.put(val, val);
   }
   return val;
 }
Beispiel #5
0
 /**
  * Read an annotation attribute from the class file
  *
  * @param constantPool from constant pool being loaded
  * @param input the data being read
  */
 static RVMAnnotation readAnnotation(
     int[] constantPool, DataInputStream input, ClassLoader classLoader)
     throws IOException, ClassNotFoundException {
   TypeReference type;
   // Read type
   int typeIndex = input.readUnsignedShort();
   type = TypeReference.findOrCreate(classLoader, RVMClass.getUtf(constantPool, typeIndex));
   // Read values
   int numAnnotationMembers = input.readUnsignedShort();
   AnnotationMember[] elementValuePairs = new AnnotationMember[numAnnotationMembers];
   for (int i = 0; i < numAnnotationMembers; i++) {
     elementValuePairs[i] =
         AnnotationMember.readAnnotationMember(type, constantPool, input, classLoader);
   }
   // Arrays.sort(elementValuePairs);
   RVMAnnotation result = new RVMAnnotation(type, elementValuePairs);
   RVMAnnotation unique = uniqueMap.get(result);
   if (unique != null) {
     return unique;
   } else {
     uniqueMap.put(result, result);
     return result;
   }
 }