nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java
changeset 22379 5181d08e3440
parent 22368 9cb3e7db27c6
child 22669 75563515567f
equal deleted inserted replaced
22378:ab34b295a702 22379:5181d08e3440
   649             mv.dup();
   649             mv.dup();
   650             mv.invokespecial(UNSUPPORTED_OPERATION_TYPE_NAME, INIT, VOID_NOARG_METHOD_DESCRIPTOR, false);
   650             mv.invokespecial(UNSUPPORTED_OPERATION_TYPE_NAME, INIT, VOID_NOARG_METHOD_DESCRIPTOR, false);
   651             mv.athrow();
   651             mv.athrow();
   652         } else {
   652         } else {
   653             // If the super method is not abstract, delegate to it.
   653             // If the super method is not abstract, delegate to it.
   654             emitSuperCall(mv, name, methodDesc);
   654             emitSuperCall(mv, method.getDeclaringClass(), name, methodDesc);
   655         }
   655         }
   656 
   656 
   657         final Label setupGlobal = new Label();
   657         final Label setupGlobal = new Label();
   658 
   658 
   659         if(classOverride) {
   659         if(classOverride) {
   828 
   828 
   829         final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(getAccessModifiers(method),
   829         final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(getAccessModifiers(method),
   830                 SUPER_PREFIX + name, methodDesc, null, getExceptionNames(method.getExceptionTypes())));
   830                 SUPER_PREFIX + name, methodDesc, null, getExceptionNames(method.getExceptionTypes())));
   831         mv.visitCode();
   831         mv.visitCode();
   832 
   832 
   833         emitSuperCall(mv, name, methodDesc);
   833         emitSuperCall(mv, method.getDeclaringClass(), name, methodDesc);
   834 
   834 
   835         endMethod(mv);
   835         endMethod(mv);
   836     }
   836     }
   837 
   837 
   838     private void emitSuperCall(final InstructionAdapter mv, final String name, final String methodDesc) {
   838     private void emitSuperCall(final InstructionAdapter mv, final Class owner, final String name, final String methodDesc) {
   839         mv.visitVarInsn(ALOAD, 0);
   839         mv.visitVarInsn(ALOAD, 0);
   840         int nextParam = 1;
   840         int nextParam = 1;
   841         final Type methodType = Type.getMethodType(methodDesc);
   841         final Type methodType = Type.getMethodType(methodDesc);
   842         for(final Type t: methodType.getArgumentTypes()) {
   842         for(final Type t: methodType.getArgumentTypes()) {
   843             mv.load(nextParam, t);
   843             mv.load(nextParam, t);
   844             nextParam += t.getSize();
   844             nextParam += t.getSize();
   845         }
   845         }
   846         mv.invokespecial(superClassName, name, methodDesc, false);
   846 
       
   847         // default method - non-abstract, interface method
       
   848         if (Modifier.isInterface(owner.getModifiers())) {
       
   849             mv.invokespecial(Type.getInternalName(owner), name, methodDesc, false);
       
   850         } else {
       
   851             mv.invokespecial(superClassName, name, methodDesc, false);
       
   852         }
   847         mv.areturn(methodType.getReturnType());
   853         mv.areturn(methodType.getReturnType());
   848     }
   854     }
   849 
   855 
   850     private static String[] getExceptionNames(final Class<?>[] exceptions) {
   856     private static String[] getExceptionNames(final Class<?>[] exceptions) {
   851         final String[] exceptionNames = new String[exceptions.length];
   857         final String[] exceptionNames = new String[exceptions.length];