Beispiel #1
0
 internal static long ObjectFieldOffset(sun.misc.Unsafe UNSAFE, String field, Class klazz)
 {
     try
     {
         return(UNSAFE.objectFieldOffset(klazz.GetDeclaredField(field)));
     }
     catch (NoSuchFieldException e)
     {
         // Convert Exception to corresponding Error
         NoSuchFieldError error = new NoSuchFieldError(field);
         error.InitCause(e);
         throw error;
     }
 }
Beispiel #2
0
 /// <summary>
 /// The JVM is resolving a CONSTANT_MethodHandle CP entry.  And it wants our help.
 /// It will make an up-call to this method.  (Do not change the name or signature.)
 /// The type argument is a Class for field requests and a MethodType for non-fields.
 /// <para>
 /// Recent versions of the JVM may also pass a resolved MemberName for the type.
 /// In that case, the name is ignored and may be null.
 /// </para>
 /// </summary>
 internal static MethodHandle LinkMethodHandleConstant(Class callerClass, int refKind, Class defc, String name, Object type)
 {
     try
     {
         Lookup lookup = IMPL_LOOKUP.@in(callerClass);
         assert(RefKindIsValid(refKind));
         return(lookup.linkMethodHandleConstant((sbyte)refKind, defc, name, type));
     }
     catch (IllegalAccessException ex)
     {
         Throwable cause = ex.InnerException;
         if (cause is AbstractMethodError)
         {
             throw (AbstractMethodError)cause;
         }
         else
         {
             Error err = new IllegalAccessError(ex.Message);
             throw InitCauseFrom(err, ex);
         }
     }
     catch (NoSuchMethodException ex)
     {
         Error err = new NoSuchMethodError(ex.Message);
         throw InitCauseFrom(err, ex);
     }
     catch (NoSuchFieldException ex)
     {
         Error err = new NoSuchFieldError(ex.Message);
         throw InitCauseFrom(err, ex);
     }
     catch (ReflectiveOperationException ex)
     {
         Error err = new IncompatibleClassChangeError();
         throw InitCauseFrom(err, ex);
     }
 }