Пример #1
0
 public ResolvedJavaType lookupJavaType(Constant constant) {
   if (constant.isNull() || !(constant instanceof HotSpotObjectConstant)) {
     return null;
   }
   Object o = HotSpotObjectConstant.asObject(constant);
   return HotSpotResolvedObjectType.fromClass(o.getClass());
 }
Пример #2
0
  public ResolvedJavaField lookupJavaField(Field reflectionField) {
    String name = reflectionField.getName();
    Class<?> fieldHolder = reflectionField.getDeclaringClass();
    Class<?> fieldType = reflectionField.getType();
    // java.lang.reflect.Field's modifiers should be enough here since VM internal modifier bits
    // are not used (yet).
    final int modifiers = reflectionField.getModifiers();
    final long offset =
        Modifier.isStatic(modifiers)
            ? unsafe.staticFieldOffset(reflectionField)
            : unsafe.objectFieldOffset(reflectionField);

    ResolvedJavaType holder = HotSpotResolvedObjectType.fromClass(fieldHolder);
    ResolvedJavaType type = HotSpotResolvedObjectType.fromClass(fieldType);

    if (offset != -1) {
      HotSpotResolvedObjectType resolved = (HotSpotResolvedObjectType) holder;
      return resolved.createField(name, type, offset, modifiers);
    } else {
      throw GraalInternalError.shouldNotReachHere("unresolved field " + reflectionField);
    }
  }
Пример #3
0
 public ResolvedJavaType lookupJavaType(Class<?> clazz) {
   if (clazz == null) {
     throw new IllegalArgumentException("Class parameter was null");
   }
   return HotSpotResolvedObjectType.fromClass(clazz);
 }