1.1 --- a/rt/emul/compact/src/main/java/java/lang/invoke/DirectMethodHandle.java Sat Aug 09 11:11:13 2014 +0200
1.2 +++ b/rt/emul/compact/src/main/java/java/lang/invoke/DirectMethodHandle.java Sun Aug 10 07:02:12 2014 +0200
1.3 @@ -25,7 +25,6 @@
1.4
1.5 package java.lang.invoke;
1.6
1.7 -import sun.misc.Unsafe;
1.8 import java.lang.reflect.Method;
1.9 import java.util.Arrays;
1.10 import sun.invoke.util.VerifyAccess;
1.11 @@ -326,19 +325,19 @@
1.12 VerifyAccess.isSamePackage(ValueConversions.class, cls)) {
1.13 // It is a system class. It is probably in the process of
1.14 // being initialized, but we will help it along just to be safe.
1.15 - if (UNSAFE.shouldBeInitialized(cls)) {
1.16 - UNSAFE.ensureClassInitialized(cls);
1.17 + if (shouldBeInitialized(cls)) {
1.18 + ensureClassInitialized(cls);
1.19 }
1.20 return false;
1.21 }
1.22 - return UNSAFE.shouldBeInitialized(cls);
1.23 + return shouldBeInitialized(cls);
1.24 }
1.25
1.26 private static class EnsureInitialized extends ClassValue<WeakReference<Thread>> {
1.27 @Override
1.28 protected WeakReference<Thread> computeValue(Class<?> type) {
1.29 - UNSAFE.ensureClassInitialized(type);
1.30 - if (UNSAFE.shouldBeInitialized(type))
1.31 + ensureClassInitialized(type);
1.32 + if (shouldBeInitialized(type))
1.33 // If the previous call didn't block, this can happen.
1.34 // We are executing inside <clinit>.
1.35 return new WeakReference<>(Thread.currentThread());
1.36 @@ -366,14 +365,14 @@
1.37 // Somebody may still be running defc.<clinit>.
1.38 if (clinitThread == Thread.currentThread()) {
1.39 // If anybody is running defc.<clinit>, it is this thread.
1.40 - if (UNSAFE.shouldBeInitialized(defc))
1.41 + if (shouldBeInitialized(defc))
1.42 // Yes, we are running it; keep the barrier for now.
1.43 return false;
1.44 } else {
1.45 // We are in a random thread. Block.
1.46 - UNSAFE.ensureClassInitialized(defc);
1.47 + ensureClassInitialized(defc);
1.48 }
1.49 - assert(!UNSAFE.shouldBeInitialized(defc));
1.50 + assert(!shouldBeInitialized(defc));
1.51 // put it into the final state
1.52 EnsureInitialized.INSTANCE.remove(defc);
1.53 return true;
1.54 @@ -423,7 +422,12 @@
1.55
1.56 /*non-public*/ static Object allocateInstance(Object mh) throws InstantiationException {
1.57 Constructor dmh = (Constructor)mh;
1.58 - return UNSAFE.allocateInstance(dmh.instanceClass);
1.59 + try {
1.60 + return dmh.instanceClass.newInstance();
1.61 +// return UNSAFE.allocateInstance(dmh.instanceClass);
1.62 + } catch (IllegalAccessException ex) {
1.63 + throw (InstantiationException)new InstantiationException().initCause(ex);
1.64 + }
1.65 }
1.66
1.67 /** This subclass handles non-static field references. */
1.68 @@ -603,7 +607,7 @@
1.69 linkerType = MethodType.methodType(ft, Object.class, long.class);
1.70 else
1.71 linkerType = MethodType.methodType(void.class, Object.class, long.class, ft);
1.72 - MemberName linker = new MemberName(Unsafe.class, linkerName, linkerType, REF_invokeVirtual);
1.73 + MemberName linker = null;//new MemberName(Unsafe.class, linkerName, linkerType, REF_invokeVirtual);
1.74 try {
1.75 linker = IMPL_NAMES.resolveOrFail(REF_invokeVirtual, linker, null, NoSuchMethodException.class);
1.76 } catch (ReflectiveOperationException ex) {
1.77 @@ -642,7 +646,7 @@
1.78 names[PRE_CAST] = new Name(Lazy.NF_checkCast, names[DMH_THIS], names[SET_VALUE]);
1.79 Object[] outArgs = new Object[1 + linkerType.parameterCount()];
1.80 assert(outArgs.length == (isGetter ? 3 : 4));
1.81 - outArgs[0] = UNSAFE;
1.82 +// outArgs[0] = UNSAFE;
1.83 if (isStatic) {
1.84 outArgs[1] = names[F_HOLDER] = new Name(Lazy.NF_staticBase, names[DMH_THIS]);
1.85 outArgs[2] = names[F_OFFSET] = new Name(Lazy.NF_staticOffset, names[DMH_THIS]);
1.86 @@ -707,7 +711,7 @@
1.87 };
1.88 for (NamedFunction nf : nfs) {
1.89 // Each nf must be statically invocable or we get tied up in our bootstraps.
1.90 - assert(InvokerBytecodeGenerator.isStaticallyInvocable(nf.member)) : nf;
1.91 +// assert(InvokerBytecodeGenerator.isStaticallyInvocable(nf.member)) : nf;
1.92 nf.resolve();
1.93 }
1.94 } catch (ReflectiveOperationException ex) {
1.95 @@ -715,4 +719,12 @@
1.96 }
1.97 }
1.98 }
1.99 +
1.100 + private static boolean shouldBeInitialized(Class<?> c) {
1.101 + return false;
1.102 + }
1.103 +
1.104 + private static void ensureClassInitialized(Class<?> c) {
1.105 + c.getName();
1.106 + }
1.107 }