Java Code Examples for jdk.internal.org.objectweb.asm.type#METHOD
The following examples show how to use
jdk.internal.org.objectweb.asm.type#METHOD .
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: CheckMethodAdapter.java From nashorn with GNU General Public License v2.0 | 6 votes |
void checkLDCConstant(final Object cst) { if (cst instanceof Type) { int s = ((Type) cst).getSort(); if (s != Type.OBJECT && s != Type.ARRAY && s != Type.METHOD) { throw new IllegalArgumentException("Illegal LDC constant value"); } if (s != Type.METHOD && (version & 0xFFFF) < Opcodes.V1_5) { throw new IllegalArgumentException("ldc of a constant class requires at least version 1.5"); } if (s == Type.METHOD && (version & 0xFFFF) < Opcodes.V1_7) { throw new IllegalArgumentException("ldc of a method type requires at least version 1.7"); } } else if (cst instanceof Handle) { if ((version & 0xFFFF) < Opcodes.V1_7) { throw new IllegalArgumentException("ldc of a handle requires at least version 1.7"); } int tag = ((Handle) cst).getTag(); if (tag < Opcodes.H_GETFIELD || tag > Opcodes.H_INVOKEINTERFACE) { throw new IllegalArgumentException("invalid handle tag " + tag); } } else { checkConstant(cst); } }
Example 2
Source File: CheckAnnotationAdapter.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override public void visit(final String name, final Object value) { checkEnd(); checkName(name); if (!(value instanceof Byte || value instanceof Boolean || value instanceof Character || value instanceof Short || value instanceof Integer || value instanceof Long || value instanceof Float || value instanceof Double || value instanceof String || value instanceof Type || value instanceof byte[] || value instanceof boolean[] || value instanceof char[] || value instanceof short[] || value instanceof int[] || value instanceof long[] || value instanceof float[] || value instanceof double[])) { throw new IllegalArgumentException("Invalid annotation value"); } if (value instanceof Type) { int sort = ((Type) value).getSort(); if (sort == Type.METHOD) { throw new IllegalArgumentException("Invalid annotation value"); } } if (av != null) { av.visit(name, value); } }
Example 3
Source File: CheckAnnotationAdapter.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
@Override public void visit(final String name, final Object value) { checkEnd(); checkName(name); if (!(value instanceof Byte || value instanceof Boolean || value instanceof Character || value instanceof Short || value instanceof Integer || value instanceof Long || value instanceof Float || value instanceof Double || value instanceof String || value instanceof Type || value instanceof byte[] || value instanceof boolean[] || value instanceof char[] || value instanceof short[] || value instanceof int[] || value instanceof long[] || value instanceof float[] || value instanceof double[])) { throw new IllegalArgumentException("Invalid annotation value"); } if (value instanceof Type) { int sort = ((Type) value).getSort(); if (sort == Type.METHOD) { throw new IllegalArgumentException("Invalid annotation value"); } } if (av != null) { av.visit(name, value); } }
Example 4
Source File: CheckAnnotationAdapter.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override public void visit(final String name, final Object value) { checkEnd(); checkName(name); if (!(value instanceof Byte || value instanceof Boolean || value instanceof Character || value instanceof Short || value instanceof Integer || value instanceof Long || value instanceof Float || value instanceof Double || value instanceof String || value instanceof Type || value instanceof byte[] || value instanceof boolean[] || value instanceof char[] || value instanceof short[] || value instanceof int[] || value instanceof long[] || value instanceof float[] || value instanceof double[])) { throw new IllegalArgumentException("Invalid annotation value"); } if (value instanceof Type) { int sort = ((Type) value).getSort(); if (sort == Type.METHOD) { throw new IllegalArgumentException("Invalid annotation value"); } } if (av != null) { av.visit(name, value); } }
Example 5
Source File: Remapper.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private Type mapType(Type t) { switch (t.getSort()) { case Type.ARRAY: String s = mapDesc(t.getElementType().getDescriptor()); for (int i = 0; i < t.getDimensions(); ++i) { s = '[' + s; } return Type.getType(s); case Type.OBJECT: s = map(t.getInternalName()); return s != null ? Type.getObjectType(s) : t; case Type.METHOD: return Type.getMethodType(mapMethodDesc(t.getDescriptor())); } return t; }
Example 6
Source File: Remapper.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private Type mapType(Type t) { switch (t.getSort()) { case Type.ARRAY: String s = mapDesc(t.getElementType().getDescriptor()); for (int i = 0; i < t.getDimensions(); ++i) { s = '[' + s; } return Type.getType(s); case Type.OBJECT: s = map(t.getInternalName()); return s != null ? Type.getObjectType(s) : t; case Type.METHOD: return Type.getMethodType(mapMethodDesc(t.getDescriptor())); } return t; }
Example 7
Source File: CheckAnnotationAdapter.java From hottub with GNU General Public License v2.0 | 6 votes |
@Override public void visit(final String name, final Object value) { checkEnd(); checkName(name); if (!(value instanceof Byte || value instanceof Boolean || value instanceof Character || value instanceof Short || value instanceof Integer || value instanceof Long || value instanceof Float || value instanceof Double || value instanceof String || value instanceof Type || value instanceof byte[] || value instanceof boolean[] || value instanceof char[] || value instanceof short[] || value instanceof int[] || value instanceof long[] || value instanceof float[] || value instanceof double[])) { throw new IllegalArgumentException("Invalid annotation value"); } if (value instanceof Type) { int sort = ((Type) value).getSort(); if (sort == Type.METHOD) { throw new IllegalArgumentException("Invalid annotation value"); } } if (av != null) { av.visit(name, value); } }
Example 8
Source File: Remapper.java From nashorn with GNU General Public License v2.0 | 6 votes |
private Type mapType(Type t) { switch (t.getSort()) { case Type.ARRAY: String s = mapDesc(t.getElementType().getDescriptor()); for (int i = 0; i < t.getDimensions(); ++i) { s = '[' + s; } return Type.getType(s); case Type.OBJECT: s = map(t.getInternalName()); return s != null ? Type.getObjectType(s) : t; case Type.METHOD: return Type.getMethodType(mapMethodDesc(t.getDescriptor())); } return t; }
Example 9
Source File: CheckAnnotationAdapter.java From Bytecoder with Apache License 2.0 | 5 votes |
@Override public void visit(final String name, final Object value) { checkVisitEndNotCalled(); checkName(name); if (!(value instanceof Byte || value instanceof Boolean || value instanceof Character || value instanceof Short || value instanceof Integer || value instanceof Long || value instanceof Float || value instanceof Double || value instanceof String || value instanceof Type || value instanceof byte[] || value instanceof boolean[] || value instanceof char[] || value instanceof short[] || value instanceof int[] || value instanceof long[] || value instanceof float[] || value instanceof double[])) { throw new IllegalArgumentException("Invalid annotation value"); } if (value instanceof Type && ((Type) value).getSort() == Type.METHOD) { throw new IllegalArgumentException("Invalid annotation value"); } super.visit(name, value); }
Example 10
Source File: InstructionAdapter.java From Bytecoder with Apache License 2.0 | 5 votes |
@Override public void visitLdcInsn(final Object value) { if (api < Opcodes.ASM5 && (value instanceof Handle || (value instanceof Type && ((Type) value).getSort() == Type.METHOD))) { throw new UnsupportedOperationException("This feature requires ASM5"); } if (api != Opcodes.ASM7 && value instanceof ConstantDynamic) { throw new UnsupportedOperationException("This feature requires ASM7"); } if (value instanceof Integer) { iconst((Integer) value); } else if (value instanceof Byte) { iconst(((Byte) value).intValue()); } else if (value instanceof Character) { iconst(((Character) value).charValue()); } else if (value instanceof Short) { iconst(((Short) value).intValue()); } else if (value instanceof Boolean) { iconst(((Boolean) value).booleanValue() ? 1 : 0); } else if (value instanceof Float) { fconst((Float) value); } else if (value instanceof Long) { lconst((Long) value); } else if (value instanceof Double) { dconst((Double) value); } else if (value instanceof String) { aconst(value); } else if (value instanceof Type) { tconst((Type) value); } else if (value instanceof Handle) { hconst((Handle) value); } else if (value instanceof ConstantDynamic) { cconst((ConstantDynamic) value); } else { throw new IllegalArgumentException(); } }
Example 11
Source File: CheckMethodAdapter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
void checkLDCConstant(final Object cst) { if (cst instanceof Type) { int s = ((Type) cst).getSort(); if (s != Type.OBJECT && s != Type.ARRAY && s != Type.METHOD) { throw new IllegalArgumentException("Illegal LDC constant value"); } if (s != Type.METHOD && (version & 0xFFFF) < Opcodes.V1_5) { throw new IllegalArgumentException( "ldc of a constant class requires at least version 1.5"); } if (s == Type.METHOD && (version & 0xFFFF) < Opcodes.V1_7) { throw new IllegalArgumentException( "ldc of a method type requires at least version 1.7"); } } else if (cst instanceof Handle) { if ((version & 0xFFFF) < Opcodes.V1_7) { throw new IllegalArgumentException( "ldc of a handle requires at least version 1.7"); } int tag = ((Handle) cst).getTag(); if (tag < Opcodes.H_GETFIELD || tag > Opcodes.H_INVOKEINTERFACE) { throw new IllegalArgumentException("invalid handle tag " + tag); } } else { checkConstant(cst); } }
Example 12
Source File: AnalyzerAdapter.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Override public void visitLdcInsn(final Object cst) { if (mv != null) { mv.visitLdcInsn(cst); } if (this.locals == null) { labels = null; return; } if (cst instanceof Integer) { push(Opcodes.INTEGER); } else if (cst instanceof Long) { push(Opcodes.LONG); push(Opcodes.TOP); } else if (cst instanceof Float) { push(Opcodes.FLOAT); } else if (cst instanceof Double) { push(Opcodes.DOUBLE); push(Opcodes.TOP); } else if (cst instanceof String) { push("java/lang/String"); } else if (cst instanceof Type) { int sort = ((Type) cst).getSort(); if (sort == Type.OBJECT || sort == Type.ARRAY) { push("java/lang/Class"); } else if (sort == Type.METHOD) { push("java/lang/invoke/MethodType"); } else { throw new IllegalArgumentException(); } } else if (cst instanceof Handle) { push("java/lang/invoke/MethodHandle"); } else { throw new IllegalArgumentException(); } labels = null; }
Example 13
Source File: CheckMethodAdapter.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
void checkLDCConstant(final Object cst) { if (cst instanceof Type) { int s = ((Type) cst).getSort(); if (s != Type.OBJECT && s != Type.ARRAY && s != Type.METHOD) { throw new IllegalArgumentException("Illegal LDC constant value"); } if (s != Type.METHOD && (version & 0xFFFF) < Opcodes.V1_5) { throw new IllegalArgumentException( "ldc of a constant class requires at least version 1.5"); } if (s == Type.METHOD && (version & 0xFFFF) < Opcodes.V1_7) { throw new IllegalArgumentException( "ldc of a method type requires at least version 1.7"); } } else if (cst instanceof Handle) { if ((version & 0xFFFF) < Opcodes.V1_7) { throw new IllegalArgumentException( "ldc of a handle requires at least version 1.7"); } int tag = ((Handle) cst).getTag(); if (tag < Opcodes.H_GETFIELD || tag > Opcodes.H_INVOKEINTERFACE) { throw new IllegalArgumentException("invalid handle tag " + tag); } } else { checkConstant(cst); } }
Example 14
Source File: BasicInterpreter.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public BasicValue newOperation(final AbstractInsnNode insn) throws AnalyzerException { switch (insn.getOpcode()) { case ACONST_NULL: return newValue(Type.getObjectType("null")); case ICONST_M1: case ICONST_0: case ICONST_1: case ICONST_2: case ICONST_3: case ICONST_4: case ICONST_5: return BasicValue.INT_VALUE; case LCONST_0: case LCONST_1: return BasicValue.LONG_VALUE; case FCONST_0: case FCONST_1: case FCONST_2: return BasicValue.FLOAT_VALUE; case DCONST_0: case DCONST_1: return BasicValue.DOUBLE_VALUE; case BIPUSH: case SIPUSH: return BasicValue.INT_VALUE; case LDC: Object cst = ((LdcInsnNode) insn).cst; if (cst instanceof Integer) { return BasicValue.INT_VALUE; } else if (cst instanceof Float) { return BasicValue.FLOAT_VALUE; } else if (cst instanceof Long) { return BasicValue.LONG_VALUE; } else if (cst instanceof Double) { return BasicValue.DOUBLE_VALUE; } else if (cst instanceof String) { return newValue(Type.getObjectType("java/lang/String")); } else if (cst instanceof Type) { int sort = ((Type) cst).getSort(); if (sort == Type.OBJECT || sort == Type.ARRAY) { return newValue(Type.getObjectType("java/lang/Class")); } else if (sort == Type.METHOD) { return newValue(Type .getObjectType("java/lang/invoke/MethodType")); } else { throw new IllegalArgumentException("Illegal LDC constant " + cst); } } else if (cst instanceof Handle) { return newValue(Type .getObjectType("java/lang/invoke/MethodHandle")); } else { throw new IllegalArgumentException("Illegal LDC constant " + cst); } case JSR: return BasicValue.RETURNADDRESS_VALUE; case GETSTATIC: return newValue(Type.getType(((FieldInsnNode) insn).desc)); case NEW: return newValue(Type.getObjectType(((TypeInsnNode) insn).desc)); default: throw new Error("Internal error."); } }
Example 15
Source File: Textifier.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
@Override public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) { buf.setLength(0); buf.append(tab2).append("INVOKEDYNAMIC").append(' '); buf.append(name); appendDescriptor(METHOD_DESCRIPTOR, desc); buf.append(" ["); buf.append('\n'); buf.append(tab3); appendHandle(bsm); buf.append('\n'); buf.append(tab3).append("// arguments:"); if (bsmArgs.length == 0) { buf.append(" none"); } else { buf.append('\n'); for (int i = 0; i < bsmArgs.length; i++) { buf.append(tab3); Object cst = bsmArgs[i]; if (cst instanceof String) { Printer.appendString(buf, (String) cst); } else if (cst instanceof Type) { Type type = (Type) cst; if(type.getSort() == Type.METHOD){ appendDescriptor(METHOD_DESCRIPTOR, type.getDescriptor()); } else { buf.append(type.getDescriptor()).append(".class"); } } else if (cst instanceof Handle) { appendHandle((Handle) cst); } else { buf.append(cst); } buf.append(", \n"); } buf.setLength(buf.length() - 3); } buf.append('\n'); buf.append(tab2).append("]\n"); text.add(buf.toString()); }
Example 16
Source File: BasicInterpreter.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Override public BasicValue newOperation(final AbstractInsnNode insn) throws AnalyzerException { switch (insn.getOpcode()) { case ACONST_NULL: return newValue(Type.getObjectType("null")); case ICONST_M1: case ICONST_0: case ICONST_1: case ICONST_2: case ICONST_3: case ICONST_4: case ICONST_5: return BasicValue.INT_VALUE; case LCONST_0: case LCONST_1: return BasicValue.LONG_VALUE; case FCONST_0: case FCONST_1: case FCONST_2: return BasicValue.FLOAT_VALUE; case DCONST_0: case DCONST_1: return BasicValue.DOUBLE_VALUE; case BIPUSH: case SIPUSH: return BasicValue.INT_VALUE; case LDC: Object cst = ((LdcInsnNode) insn).cst; if (cst instanceof Integer) { return BasicValue.INT_VALUE; } else if (cst instanceof Float) { return BasicValue.FLOAT_VALUE; } else if (cst instanceof Long) { return BasicValue.LONG_VALUE; } else if (cst instanceof Double) { return BasicValue.DOUBLE_VALUE; } else if (cst instanceof String) { return newValue(Type.getObjectType("java/lang/String")); } else if (cst instanceof Type) { int sort = ((Type) cst).getSort(); if (sort == Type.OBJECT || sort == Type.ARRAY) { return newValue(Type.getObjectType("java/lang/Class")); } else if (sort == Type.METHOD) { return newValue(Type .getObjectType("java/lang/invoke/MethodType")); } else { throw new IllegalArgumentException("Illegal LDC constant " + cst); } } else if (cst instanceof Handle) { return newValue(Type .getObjectType("java/lang/invoke/MethodHandle")); } else { throw new IllegalArgumentException("Illegal LDC constant " + cst); } case JSR: return BasicValue.RETURNADDRESS_VALUE; case GETSTATIC: return newValue(Type.getType(((FieldInsnNode) insn).desc)); case NEW: return newValue(Type.getObjectType(((TypeInsnNode) insn).desc)); default: throw new Error("Internal error."); } }
Example 17
Source File: Textifier.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
@Override public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) { buf.setLength(0); buf.append(tab2).append("INVOKEDYNAMIC").append(' '); buf.append(name); appendDescriptor(METHOD_DESCRIPTOR, desc); buf.append(" ["); buf.append('\n'); buf.append(tab3); appendHandle(bsm); buf.append('\n'); buf.append(tab3).append("// arguments:"); if (bsmArgs.length == 0) { buf.append(" none"); } else { buf.append('\n'); for (int i = 0; i < bsmArgs.length; i++) { buf.append(tab3); Object cst = bsmArgs[i]; if (cst instanceof String) { Printer.appendString(buf, (String) cst); } else if (cst instanceof Type) { Type type = (Type) cst; if(type.getSort() == Type.METHOD){ appendDescriptor(METHOD_DESCRIPTOR, type.getDescriptor()); } else { buf.append(type.getDescriptor()).append(".class"); } } else if (cst instanceof Handle) { appendHandle((Handle) cst); } else { buf.append(cst); } buf.append(", \n"); } buf.setLength(buf.length() - 3); } buf.append('\n'); buf.append(tab2).append("]\n"); text.add(buf.toString()); }
Example 18
Source File: BasicInterpreter.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Override public BasicValue newOperation(final AbstractInsnNode insn) throws AnalyzerException { switch (insn.getOpcode()) { case ACONST_NULL: return newValue(Type.getObjectType("null")); case ICONST_M1: case ICONST_0: case ICONST_1: case ICONST_2: case ICONST_3: case ICONST_4: case ICONST_5: return BasicValue.INT_VALUE; case LCONST_0: case LCONST_1: return BasicValue.LONG_VALUE; case FCONST_0: case FCONST_1: case FCONST_2: return BasicValue.FLOAT_VALUE; case DCONST_0: case DCONST_1: return BasicValue.DOUBLE_VALUE; case BIPUSH: case SIPUSH: return BasicValue.INT_VALUE; case LDC: Object cst = ((LdcInsnNode) insn).cst; if (cst instanceof Integer) { return BasicValue.INT_VALUE; } else if (cst instanceof Float) { return BasicValue.FLOAT_VALUE; } else if (cst instanceof Long) { return BasicValue.LONG_VALUE; } else if (cst instanceof Double) { return BasicValue.DOUBLE_VALUE; } else if (cst instanceof String) { return newValue(Type.getObjectType("java/lang/String")); } else if (cst instanceof Type) { int sort = ((Type) cst).getSort(); if (sort == Type.OBJECT || sort == Type.ARRAY) { return newValue(Type.getObjectType("java/lang/Class")); } else if (sort == Type.METHOD) { return newValue(Type .getObjectType("java/lang/invoke/MethodType")); } else { throw new IllegalArgumentException("Illegal LDC constant " + cst); } } else if (cst instanceof Handle) { return newValue(Type .getObjectType("java/lang/invoke/MethodHandle")); } else { throw new IllegalArgumentException("Illegal LDC constant " + cst); } case JSR: return BasicValue.RETURNADDRESS_VALUE; case GETSTATIC: return newValue(Type.getType(((FieldInsnNode) insn).desc)); case NEW: return newValue(Type.getObjectType(((TypeInsnNode) insn).desc)); default: throw new Error("Internal error."); } }
Example 19
Source File: Textifier.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
@Override public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) { buf.setLength(0); buf.append(tab2).append("INVOKEDYNAMIC").append(' '); buf.append(name); appendDescriptor(METHOD_DESCRIPTOR, desc); buf.append(" ["); buf.append('\n'); buf.append(tab3); appendHandle(bsm); buf.append('\n'); buf.append(tab3).append("// arguments:"); if (bsmArgs.length == 0) { buf.append(" none"); } else { buf.append('\n'); for (int i = 0; i < bsmArgs.length; i++) { buf.append(tab3); Object cst = bsmArgs[i]; if (cst instanceof String) { Printer.appendString(buf, (String) cst); } else if (cst instanceof Type) { Type type = (Type) cst; if(type.getSort() == Type.METHOD){ appendDescriptor(METHOD_DESCRIPTOR, type.getDescriptor()); } else { buf.append(type.getDescriptor()).append(".class"); } } else if (cst instanceof Handle) { appendHandle((Handle) cst); } else { buf.append(cst); } buf.append(", \n"); } buf.setLength(buf.length() - 3); } buf.append('\n'); buf.append(tab2).append("]\n"); text.add(buf.toString()); }
Example 20
Source File: Textifier.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Override public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) { buf.setLength(0); buf.append(tab2).append("INVOKEDYNAMIC").append(' '); buf.append(name); appendDescriptor(METHOD_DESCRIPTOR, desc); buf.append(" ["); buf.append('\n'); buf.append(tab3); appendHandle(bsm); buf.append('\n'); buf.append(tab3).append("// arguments:"); if (bsmArgs.length == 0) { buf.append(" none"); } else { buf.append('\n'); for (int i = 0; i < bsmArgs.length; i++) { buf.append(tab3); Object cst = bsmArgs[i]; if (cst instanceof String) { Printer.appendString(buf, (String) cst); } else if (cst instanceof Type) { Type type = (Type) cst; if(type.getSort() == Type.METHOD){ appendDescriptor(METHOD_DESCRIPTOR, type.getDescriptor()); } else { buf.append(type.getDescriptor()).append(".class"); } } else if (cst instanceof Handle) { appendHandle((Handle) cst); } else { buf.append(cst); } buf.append(", \n"); } buf.setLength(buf.length() - 3); } buf.append('\n'); buf.append(tab2).append("]\n"); text.add(buf.toString()); }