Java Code Examples for org.objectweb.asm.Opcodes#INTEGER
The following examples show how to use
org.objectweb.asm.Opcodes#INTEGER .
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 Concurnas with MIT License | 7 votes |
/** * Checks a stack frame value. * * @param value the value to be checked. */ private void checkFrameValue(final Object value) { if (value == Opcodes.TOP || value == Opcodes.INTEGER || value == Opcodes.FLOAT || value == Opcodes.LONG || value == Opcodes.DOUBLE || value == Opcodes.NULL || value == Opcodes.UNINITIALIZED_THIS) { return; } else if (value instanceof String) { checkInternalName(version, (String) value, "Invalid stack frame value"); } else if (value instanceof Label) { referencedLabels.add((Label) value); } else { throw new IllegalArgumentException("Invalid stack frame value: " + value); } }
Example 2
Source File: CheckMethodAdapter.java From JByteMod-Beta with GNU General Public License v2.0 | 6 votes |
/** * Checks a stack frame value. * * @param value * the value to be checked. */ void checkFrameValue(final Object value) { if (value == Opcodes.TOP || value == Opcodes.INTEGER || value == Opcodes.FLOAT || value == Opcodes.LONG || value == Opcodes.DOUBLE || value == Opcodes.NULL || value == Opcodes.UNINITIALIZED_THIS) { return; } if (value instanceof String) { checkInternalName((String) value, "Invalid stack frame value"); return; } if (!(value instanceof Label)) { throw new IllegalArgumentException("Invalid stack frame value: " + value); } else { usedLabels.add((Label) value); } }
Example 3
Source File: CheckMethodAdapter.java From JReFrameworker with MIT License | 6 votes |
/** * Checks a stack frame value. * * @param value the value to be checked. */ private void checkFrameValue(final Object value) { if (value == Opcodes.TOP || value == Opcodes.INTEGER || value == Opcodes.FLOAT || value == Opcodes.LONG || value == Opcodes.DOUBLE || value == Opcodes.NULL || value == Opcodes.UNINITIALIZED_THIS) { return; } else if (value instanceof String) { checkInternalName(version, (String) value, "Invalid stack frame value"); } else if (value instanceof Label) { referencedLabels.add((Label) value); } else { throw new IllegalArgumentException("Invalid stack frame value: " + value); } }
Example 4
Source File: CheckMethodAdapter.java From JReFrameworker with MIT License | 6 votes |
/** * Checks a stack frame value. * * @param value the value to be checked. */ private void checkFrameValue(final Object value) { if (value == Opcodes.TOP || value == Opcodes.INTEGER || value == Opcodes.FLOAT || value == Opcodes.LONG || value == Opcodes.DOUBLE || value == Opcodes.NULL || value == Opcodes.UNINITIALIZED_THIS) { return; } else if (value instanceof String) { checkInternalName(version, (String) value, "Invalid stack frame value"); } else if (value instanceof Label) { referencedLabels.add((Label) value); } else { throw new IllegalArgumentException("Invalid stack frame value: " + value); } }
Example 5
Source File: StackInfo.java From copper-engine with Apache License 2.0 | 6 votes |
static Type deferLocalDesc(Object object) { if (object instanceof String) return Type.getObjectType((String) object); // TODO: analyze opcode at pos label if (object instanceof Label) return Type.getType(Object.class); int intObject = (Integer) object; if (intObject == Opcodes.TOP) return null; if (intObject == Opcodes.INTEGER) return Type.INT_TYPE; if (intObject == Opcodes.FLOAT) return Type.FLOAT_TYPE; if (intObject == Opcodes.LONG) return Type.LONG_TYPE; if (intObject == Opcodes.DOUBLE) return Type.getType(double.class); if (intObject == Opcodes.LONG) return Type.getType(long.class); if (intObject == Opcodes.NULL) return Type.getType(Object.class); // TODO: defer from containing class if (intObject == Opcodes.UNINITIALIZED_THIS) return Type.getType(Object.class); throw new BuildStackFrameException("Couldnt defer desc for " + object); }
Example 6
Source File: LocalVariablesSorter.java From Concurnas with MIT License | 5 votes |
/** * Constructs a new local variable of the given type. * * @param type the type of the local variable to be created. * @return the identifier of the newly created local variable. */ public int newLocal(final Type type) { Object localType; switch (type.getSort()) { case Type.BOOLEAN: case Type.CHAR: case Type.BYTE: case Type.SHORT: case Type.INT: localType = Opcodes.INTEGER; break; case Type.FLOAT: localType = Opcodes.FLOAT; break; case Type.LONG: localType = Opcodes.LONG; break; case Type.DOUBLE: localType = Opcodes.DOUBLE; break; case Type.ARRAY: localType = type.getDescriptor(); break; case Type.OBJECT: localType = type.getInternalName(); break; default: throw new AssertionError(); } int local = newLocalMapping(type); setLocalType(local, type); setFrameLocal(local, localType); return local; }
Example 7
Source File: LocalVariablesSorter.java From JByteMod-Beta with GNU General Public License v2.0 | 5 votes |
/** * Constructs a new local variable of the given type. * * @param type the type of the local variable to be created. * @return the identifier of the newly created local variable. */ public int newLocal(final Type type) { Object localType; switch (type.getSort()) { case Type.BOOLEAN: case Type.CHAR: case Type.BYTE: case Type.SHORT: case Type.INT: localType = Opcodes.INTEGER; break; case Type.FLOAT: localType = Opcodes.FLOAT; break; case Type.LONG: localType = Opcodes.LONG; break; case Type.DOUBLE: localType = Opcodes.DOUBLE; break; case Type.ARRAY: localType = type.getDescriptor(); break; case Type.OBJECT: localType = type.getInternalName(); break; default: throw new AssertionError(); } int local = newLocalMapping(type); setLocalType(local, type); setFrameLocal(local, localType); return local; }
Example 8
Source File: ASMClassParser.java From TickDynamic with MIT License | 5 votes |
protected Object parseFrameType(Map<String, Label> labels, String typeStr) throws Exception { if(typeStr.length() == 1) //Base type { if(typeStr.equals("T")) return Opcodes.TOP; else if(typeStr.equals("I")) return Opcodes.INTEGER; else if(typeStr.equals("F")) return Opcodes.FLOAT; else if(typeStr.equals("D")) return Opcodes.DOUBLE; else if(typeStr.equals("J")) return Opcodes.LONG; else if(typeStr.equals("N")) return Opcodes.NULL; else if(typeStr.equals("U")) return Opcodes.UNINITIALIZED_THIS; else throw new Exception(getCurrentTokenLine() + ": Error while parsing frame type, found no type for " + typeStr); } //Label if(typeStr.startsWith("L") && StringUtils.isNumeric(typeStr.substring(1))) return getLabel(labels, typeStr); //Class name return typeStr; }
Example 9
Source File: LocalVariablesSorter.java From JReFrameworker with MIT License | 5 votes |
/** * Constructs a new local variable of the given type. * * @param type the type of the local variable to be created. * @return the identifier of the newly created local variable. */ public int newLocal(final Type type) { Object localType; switch (type.getSort()) { case Type.BOOLEAN: case Type.CHAR: case Type.BYTE: case Type.SHORT: case Type.INT: localType = Opcodes.INTEGER; break; case Type.FLOAT: localType = Opcodes.FLOAT; break; case Type.LONG: localType = Opcodes.LONG; break; case Type.DOUBLE: localType = Opcodes.DOUBLE; break; case Type.ARRAY: localType = type.getDescriptor(); break; case Type.OBJECT: localType = type.getInternalName(); break; default: throw new AssertionError(); } int local = newLocalMapping(type); setLocalType(local, type); setFrameLocal(local, localType); return local; }
Example 10
Source File: LocalVariablesSorter.java From JReFrameworker with MIT License | 5 votes |
/** * Constructs a new local variable of the given type. * * @param type the type of the local variable to be created. * @return the identifier of the newly created local variable. */ public int newLocal(final Type type) { Object localType; switch (type.getSort()) { case Type.BOOLEAN: case Type.CHAR: case Type.BYTE: case Type.SHORT: case Type.INT: localType = Opcodes.INTEGER; break; case Type.FLOAT: localType = Opcodes.FLOAT; break; case Type.LONG: localType = Opcodes.LONG; break; case Type.DOUBLE: localType = Opcodes.DOUBLE; break; case Type.ARRAY: localType = type.getDescriptor(); break; case Type.OBJECT: localType = type.getInternalName(); break; default: throw new AssertionError(); } int local = newLocalMapping(type); setLocalType(local, type); setFrameLocal(local, localType); return local; }
Example 11
Source File: BytecodeTypeInference.java From bazel with Apache License 2.0 | 5 votes |
/** Convert the type in stack map frame to inference type. */ private InferredType convertTypeInStackMapFrame(Object typeInStackMapFrame) { if (typeInStackMapFrame == Opcodes.TOP) { return InferredType.TOP; } else if (typeInStackMapFrame == Opcodes.INTEGER) { return InferredType.INT; } else if (typeInStackMapFrame == Opcodes.FLOAT) { return InferredType.FLOAT; } else if (typeInStackMapFrame == Opcodes.DOUBLE) { return InferredType.DOUBLE; } else if (typeInStackMapFrame == Opcodes.LONG) { return InferredType.LONG; } else if (typeInStackMapFrame == Opcodes.NULL) { return InferredType.NULL; } else if (typeInStackMapFrame == Opcodes.UNINITIALIZED_THIS) { return InferredType.UNINITIALIZED_THIS; } else if (typeInStackMapFrame instanceof String) { String referenceTypeName = (String) typeInStackMapFrame; if (referenceTypeName.charAt(0) == '[') { return InferredType.create(referenceTypeName); } else { return InferredType.create('L' + referenceTypeName + ';'); } } else if (typeInStackMapFrame instanceof Label) { return InferredType.UNINITIALIZED; } else { throw new RuntimeException( "Cannot reach here. Unhandled element: value=" + typeInStackMapFrame + ", class=" + typeInStackMapFrame.getClass() + ". The current method being desugared is " + methodSignature); } }
Example 12
Source File: BytecodeVerificationTest.java From AVM with MIT License | 4 votes |
@Test public void testMaxStackSizeWithLoop() throws Exception { int originalHash = 1; TestResource original = new TestResource(originalHash); ClassRewriter.IMethodReplacer replacer = new ClassRewriter.IMethodReplacer() { @Override public void populatMethod(MethodVisitor visitor) { visitor.visitCode(); Label start = new Label(); Object[] newstack = new Object[1]; newstack[0] = Opcodes.INTEGER; visitor.visitLabel(start); //visitor.visitFrame(Opcodes.F_FULL, 0, null, 1, newstack); visitor.visitFrame(Opcodes.F_FULL, 0, null, 0, null); visitor.visitVarInsn(Opcodes.BIPUSH, 0); visitor.visitJumpInsn(Opcodes.GOTO, start); visitor.visitInsn(Opcodes.IRETURN); visitor.visitMaxs(100, 100); visitor.visitEnd(); }}; String className = original.getClass().getName(); byte[] raw = Utilities.loadRequiredResourceAsBytes(className.replaceAll("\\.", "/") + ".class"); byte[] rewrittten = ClassRewriter.rewriteOneMethodInClass(raw, "hashCode", replacer, 0); Map<String, byte[]> classes = new HashMap<>(); classes.put(className, rewrittten); AvmClassLoader loader = NodeEnvironment.singleton.createInvocationClassLoader(classes); Class<?> clazz = loader.loadClass(className); try{ Object target = clazz.getConstructor(int.class).newInstance(Integer.valueOf(originalHash)); target.hashCode(); Assert.assertEquals(1,0); }catch (Error e){ Boolean expectedError = e.getMessage().contains("Inconsistent stackmap frames at branch target") ? true : false; Assert.assertEquals(expectedError, true); } }