Java Code Examples for jdk.internal.org.objectweb.asm.commons.InstructionAdapter#checkcast()
The following examples show how to use
jdk.internal.org.objectweb.asm.commons.InstructionAdapter#checkcast() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaAdapterBytecodeGenerator.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private void generateClassInit() { final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_STATIC, CLASS_INIT, VOID_METHOD_DESCRIPTOR, null, null)); // Assign "global = Context.getGlobal()" GET_NON_NULL_GLOBAL.invoke(mv); mv.putstatic(generatedClassName, GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR); GET_CLASS_OVERRIDES.invoke(mv); if(samName != null) { // If the class is a SAM, allow having ScriptFunction passed as class overrides mv.dup(); mv.instanceOf(SCRIPT_FUNCTION_TYPE); mv.dup(); mv.putstatic(generatedClassName, IS_FUNCTION_FIELD_NAME, BOOLEAN_TYPE_DESCRIPTOR); final Label notFunction = new Label(); mv.ifeq(notFunction); mv.dup(); mv.checkcast(SCRIPT_FUNCTION_TYPE); emitInitCallThis(mv); mv.visitLabel(notFunction); } mv.putstatic(generatedClassName, DELEGATE_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR); endInitMethod(mv); }
Example 2
Source File: JavaAdapterBytecodeGenerator.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void generateFinalizerDelegate(final String finalizerDelegateName) { // Generate a delegate that will be invoked from the no-permission trampoline. Note it can be private, as we'll // refer to it with a MethodHandle constant pool entry in the overridden finalize() method (see // generateFinalizerOverride()). final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PRIVATE | ACC_STATIC, finalizerDelegateName, Type.getMethodDescriptor(Type.VOID_TYPE, OBJECT_TYPE), null, null)); // Simply invoke super.finalize() mv.visitVarInsn(ALOAD, 0); mv.checkcast(Type.getType(generatedClassName)); mv.invokespecial(superClassName, "finalize", Type.getMethodDescriptor(Type.VOID_TYPE), false); mv.visitInsn(RETURN); endMethod(mv); }
Example 3
Source File: JavaAdapterBytecodeGenerator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private void generateFinalizerDelegate(final String finalizerDelegateName) { // Generate a delegate that will be invoked from the no-permission trampoline. Note it can be private, as we'll // refer to it with a MethodHandle constant pool entry in the overridden finalize() method (see // generateFinalizerOverride()). final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PRIVATE | ACC_STATIC, finalizerDelegateName, Type.getMethodDescriptor(Type.VOID_TYPE, OBJECT_TYPE), null, null)); // Simply invoke super.finalize() mv.visitVarInsn(ALOAD, 0); mv.checkcast(Type.getType(generatedClassName)); mv.invokespecial(superClassName, "finalize", Type.getMethodDescriptor(Type.VOID_TYPE), false); mv.visitInsn(RETURN); endMethod(mv); }
Example 4
Source File: JavaAdapterBytecodeGenerator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private void generateFinalizerDelegate(final String finalizerDelegateName) { // Generate a delegate that will be invoked from the no-permission trampoline. Note it can be private, as we'll // refer to it with a MethodHandle constant pool entry in the overridden finalize() method (see // generateFinalizerOverride()). final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PRIVATE | ACC_STATIC, finalizerDelegateName, Type.getMethodDescriptor(Type.VOID_TYPE, OBJECT_TYPE), null, null)); // Simply invoke super.finalize() mv.visitVarInsn(ALOAD, 0); mv.checkcast(Type.getType(generatedClassName)); mv.invokespecial(superClassName, "finalize", Type.getMethodDescriptor(Type.VOID_TYPE), false); mv.visitInsn(RETURN); endMethod(mv); }
Example 5
Source File: JavaAdapterBytecodeGenerator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private void generateFinalizerDelegate(final String finalizerDelegateName) { // Generate a delegate that will be invoked from the no-permission trampoline. Note it can be private, as we'll // refer to it with a MethodHandle constant pool entry in the overridden finalize() method (see // generateFinalizerOverride()). final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PRIVATE | ACC_STATIC, finalizerDelegateName, Type.getMethodDescriptor(Type.VOID_TYPE, OBJECT_TYPE), null, null)); // Simply invoke super.finalize() mv.visitVarInsn(ALOAD, 0); mv.checkcast(Type.getType(generatedClassName)); mv.invokespecial(superClassName, "finalize", Type.getMethodDescriptor(Type.VOID_TYPE), false); mv.visitInsn(RETURN); endMethod(mv); }
Example 6
Source File: JavaAdapterBytecodeGenerator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void generateFinalizerDelegate() { // Generate a delegate that will be invoked from the no-permission trampoline. Note it can be private, as we'll // refer to it with a MethodHandle constant pool entry in the overridden finalize() method (see // generateFinalizerOverride()). final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PRIVATE | ACC_STATIC, FINALIZER_DELEGATE_NAME, FINALIZER_DELEGATE_METHOD_DESCRIPTOR, null, null)); // Simply invoke super.finalize() mv.visitVarInsn(ALOAD, 0); mv.checkcast(Type.getType(generatedClassName)); mv.invokespecial(superClassName, "finalize", VOID_METHOD_DESCRIPTOR, false); mv.visitInsn(RETURN); endMethod(mv); }
Example 7
Source File: JavaAdapterBytecodeGenerator.java From hottub with GNU General Public License v2.0 | 5 votes |
private void generateFinalizerDelegate(final String finalizerDelegateName) { // Generate a delegate that will be invoked from the no-permission trampoline. Note it can be private, as we'll // refer to it with a MethodHandle constant pool entry in the overridden finalize() method (see // generateFinalizerOverride()). final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PRIVATE | ACC_STATIC, finalizerDelegateName, Type.getMethodDescriptor(Type.VOID_TYPE, OBJECT_TYPE), null, null)); // Simply invoke super.finalize() mv.visitVarInsn(ALOAD, 0); mv.checkcast(Type.getType(generatedClassName)); mv.invokespecial(superClassName, "finalize", Type.getMethodDescriptor(Type.VOID_TYPE), false); mv.visitInsn(RETURN); endMethod(mv); }
Example 8
Source File: JavaAdapterBytecodeGenerator.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private void generateFinalizerDelegate(final String finalizerDelegateName) { // Generate a delegate that will be invoked from the no-permission trampoline. Note it can be private, as we'll // refer to it with a MethodHandle constant pool entry in the overridden finalize() method (see // generateFinalizerOverride()). final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PRIVATE | ACC_STATIC, finalizerDelegateName, Type.getMethodDescriptor(Type.VOID_TYPE, OBJECT_TYPE), null, null)); // Simply invoke super.finalize() mv.visitVarInsn(ALOAD, 0); mv.checkcast(Type.getType(generatedClassName)); mv.invokespecial(superClassName, "finalize", Type.getMethodDescriptor(Type.VOID_TYPE), false); mv.visitInsn(RETURN); endMethod(mv); }
Example 9
Source File: JavaAdapterBytecodeGenerator.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private void generateFinalizerDelegate(final String finalizerDelegateName) { // Generate a delegate that will be invoked from the no-permission trampoline. Note it can be private, as we'll // refer to it with a MethodHandle constant pool entry in the overridden finalize() method (see // generateFinalizerOverride()). final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PRIVATE | ACC_STATIC, finalizerDelegateName, Type.getMethodDescriptor(Type.VOID_TYPE, OBJECT_TYPE), null, null)); // Simply invoke super.finalize() mv.visitVarInsn(ALOAD, 0); mv.checkcast(Type.getType(generatedClassName)); mv.invokespecial(superClassName, "finalize", Type.getMethodDescriptor(Type.VOID_TYPE), false); mv.visitInsn(RETURN); endMethod(mv); }
Example 10
Source File: JavaAdapterBytecodeGenerator.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
private void generateFinalizerDelegate(final String finalizerDelegateName) { // Generate a delegate that will be invoked from the no-permission trampoline. Note it can be private, as we'll // refer to it with a MethodHandle constant pool entry in the overridden finalize() method (see // generateFinalizerOverride()). final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PRIVATE | ACC_STATIC, finalizerDelegateName, Type.getMethodDescriptor(Type.VOID_TYPE, OBJECT_TYPE), null, null)); // Simply invoke super.finalize() mv.visitVarInsn(ALOAD, 0); mv.checkcast(Type.getType(generatedClassName)); mv.invokespecial(superClassName, "finalize", Type.getMethodDescriptor(Type.VOID_TYPE), false); mv.visitInsn(RETURN); endMethod(mv); }
Example 11
Source File: JavaAdapterBytecodeGenerator.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private void generateOverridingConstructorWithObjectParam(final InstructionAdapter mv, final String ctorDescriptor) { mv.visitCode(); final int extraArgOffset = emitSuperConstructorCall(mv, ctorDescriptor); // Check for ScriptObjectMirror mv.visitVarInsn(ALOAD, extraArgOffset); mv.instanceOf(SCRIPT_OBJECT_MIRROR_TYPE); final Label notMirror = new Label(); mv.ifeq(notMirror); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, extraArgOffset); mv.iconst(0); UNWRAP_MIRROR.invoke(mv); mv.putfield(generatedClassName, DELEGATE_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR); mv.visitVarInsn(ALOAD, 0); mv.visitVarInsn(ALOAD, extraArgOffset); mv.iconst(1); UNWRAP_MIRROR.invoke(mv); mv.putfield(generatedClassName, GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR); final Label done = new Label(); if (samName != null) { mv.visitVarInsn(ALOAD, 0); mv.getfield(generatedClassName, DELEGATE_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR); mv.instanceOf(SCRIPT_FUNCTION_TYPE); mv.ifeq(done); // Assign "isFunction = true" mv.visitVarInsn(ALOAD, 0); mv.iconst(1); mv.putfield(generatedClassName, IS_FUNCTION_FIELD_NAME, BOOLEAN_TYPE_DESCRIPTOR); mv.visitVarInsn(ALOAD, 0); mv.dup(); mv.getfield(generatedClassName, DELEGATE_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR); mv.checkcast(SCRIPT_FUNCTION_TYPE); emitInitCallThis(mv); mv.goTo(done); } mv.visitLabel(notMirror); // Throw error if not a ScriptObject mv.visitVarInsn(ALOAD, extraArgOffset); NOT_AN_OBJECT.invoke(mv); mv.visitLabel(done); endInitMethod(mv); }