Wed, 30 Apr 2014 23:59:22 -0700
Merge
1.1 --- a/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java Wed Apr 30 11:17:23 2014 -0700 1.2 +++ b/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java Wed Apr 30 23:59:22 2014 -0700 1.3 @@ -131,7 +131,7 @@ 1.4 * implemented securely. 1.5 */ 1.6 final class JavaAdapterBytecodeGenerator { 1.7 - static final Type OBJECT_TYPE = Type.getType(Object.class); 1.8 + static final Type OBJECT_TYPE = Type.getType(Object.class); 1.9 1.10 static final String OBJECT_TYPE_NAME = OBJECT_TYPE.getInternalName(); 1.11 1.12 @@ -139,6 +139,7 @@ 1.13 1.14 static final String GLOBAL_FIELD_NAME = "global"; 1.15 1.16 + // "global" is declared as Object instead of Global - avoid static references to internal Nashorn classes when possible. 1.17 static final String GLOBAL_TYPE_DESCRIPTOR = OBJECT_TYPE.getDescriptor(); 1.18 1.19 static final String SET_GLOBAL_METHOD_DESCRIPTOR = Type.getMethodDescriptor(Type.VOID_TYPE, OBJECT_TYPE); 1.20 @@ -642,7 +643,7 @@ 1.21 mv.athrow(); 1.22 } else { 1.23 // If the super method is not abstract, delegate to it. 1.24 - emitSuperCall(mv, name, methodDesc); 1.25 + emitSuperCall(mv, method.getDeclaringClass(), name, methodDesc); 1.26 } 1.27 1.28 mv.visitLabel(handleDefined); 1.29 @@ -671,7 +672,7 @@ 1.30 // stack: [creatingGlobal, creatingGlobal, handle] 1.31 1.32 // Emit code for switching to the creating global 1.33 - // ScriptObject currentGlobal = Context.getGlobal(); 1.34 + // Global currentGlobal = Context.getGlobal(); 1.35 invokeGetGlobal(mv); 1.36 mv.dup(); 1.37 1.38 @@ -814,12 +815,12 @@ 1.39 SUPER_PREFIX + name, methodDesc, null, getExceptionNames(method.getExceptionTypes()))); 1.40 mv.visitCode(); 1.41 1.42 - emitSuperCall(mv, name, methodDesc); 1.43 + emitSuperCall(mv, method.getDeclaringClass(), name, methodDesc); 1.44 1.45 endMethod(mv); 1.46 } 1.47 1.48 - private void emitSuperCall(final InstructionAdapter mv, final String name, final String methodDesc) { 1.49 + private void emitSuperCall(final InstructionAdapter mv, final Class<?> owner, final String name, final String methodDesc) { 1.50 mv.visitVarInsn(ALOAD, 0); 1.51 int nextParam = 1; 1.52 final Type methodType = Type.getMethodType(methodDesc); 1.53 @@ -827,7 +828,13 @@ 1.54 mv.load(nextParam, t); 1.55 nextParam += t.getSize(); 1.56 } 1.57 - mv.invokespecial(superClassName, name, methodDesc, false); 1.58 + 1.59 + // default method - non-abstract, interface method 1.60 + if (Modifier.isInterface(owner.getModifiers())) { 1.61 + mv.invokespecial(Type.getInternalName(owner), name, methodDesc, false); 1.62 + } else { 1.63 + mv.invokespecial(superClassName, name, methodDesc, false); 1.64 + } 1.65 mv.areturn(methodType.getReturnType()); 1.66 } 1.67