Java Code Examples for org.objectweb.asm.Opcodes#V1_6
The following examples show how to use
org.objectweb.asm.Opcodes#V1_6 .
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: SourceVersionUtils.java From buck with Apache License 2.0 | 6 votes |
/** Gets the class file version corresponding to the given source version constant. */ public static int sourceVersionToClassFileVersion(SourceVersion version) { switch (version) { case RELEASE_0: return Opcodes.V1_1; // JVMS8 4.1: 1.0 and 1.1 both support version 45.3 (Opcodes.V1_1) case RELEASE_1: return Opcodes.V1_1; case RELEASE_2: return Opcodes.V1_2; case RELEASE_3: return Opcodes.V1_3; case RELEASE_4: return Opcodes.V1_4; case RELEASE_5: return Opcodes.V1_5; case RELEASE_6: return Opcodes.V1_6; case RELEASE_7: return Opcodes.V1_7; case RELEASE_8: return Opcodes.V1_8; default: throw new IllegalArgumentException(String.format("Unexpected source version: %s", version)); } }
Example 2
Source File: ASMClassParser.java From TickDynamic with MIT License | 5 votes |
protected void parseClassVersion() throws Exception { String noMatchError = "Found no class version at beginning of class!"; String value; if(!nextToken().equals("//")) throw new Exception(noMatchError); if(!nextToken().equals("class")) throw new Exception(noMatchError); if(!nextToken().equals("version")) throw new Exception(noMatchError); value = nextToken(); int version = (int)Float.parseFloat(value); switch (version) { case 50: classVersion = Opcodes.V1_6; System.out.println("V1_6"); break; case 51: classVersion = Opcodes.V1_7; break; case 52: classVersion = Opcodes.V1_8; break; default: throw new Exception("Unsuported class version: " + version); } //Move to next line and Verify nextToken(); value = nextToken(); if(!value.equals("\n")) throw new Exception("Error while parsing class version, expected \n, got: " + value); }
Example 3
Source File: SourceVersionUtils.java From buck with Apache License 2.0 | 5 votes |
/** Gets the class file version corresponding to the given source version constant. */ public static int sourceVersionToClassFileVersion(SourceVersion version) { switch (version) { case RELEASE_0: return Opcodes.V1_1; // JVMS8 4.1: 1.0 and 1.1 both support version 45.3 (Opcodes.V1_1) case RELEASE_1: return Opcodes.V1_1; case RELEASE_2: return Opcodes.V1_2; case RELEASE_3: return Opcodes.V1_3; case RELEASE_4: return Opcodes.V1_4; case RELEASE_5: return Opcodes.V1_5; case RELEASE_6: return Opcodes.V1_6; case RELEASE_7: return Opcodes.V1_7; case RELEASE_8: return Opcodes.V1_8; case RELEASE_9: return Opcodes.V9; case RELEASE_10: return Opcodes.V10; case RELEASE_11: return Opcodes.V11; default: throw new IllegalArgumentException(String.format("Unexpected source version: %s", version)); } }
Example 4
Source File: ClassCode.java From nuls-v2 with MIT License | 4 votes |
public ClassCode(ClassNode classNode) { version = classNode.version; access = classNode.access; name = classNode.name; signature = classNode.signature; superName = classNode.superName; interfaces = ListUtils.emptyIfNull(classNode.interfaces); sourceFile = classNode.sourceFile; sourceDebug = classNode.sourceDebug; module = classNode.module; outerClass = classNode.outerClass; outerMethod = classNode.outerMethod; outerMethodDesc = classNode.outerMethodDesc; visibleAnnotations = ListUtils.emptyIfNull(classNode.visibleAnnotations); invisibleAnnotations = ListUtils.emptyIfNull(classNode.invisibleAnnotations); visibleTypeAnnotations = ListUtils.emptyIfNull(classNode.visibleTypeAnnotations); invisibleTypeAnnotations = ListUtils.emptyIfNull(classNode.invisibleTypeAnnotations); attrs = ListUtils.emptyIfNull(classNode.attrs); innerClasses = ListUtils.emptyIfNull(classNode.innerClasses); nestHostClass = classNode.nestHostClass; nestMembers = ListUtils.emptyIfNull(classNode.nestMembers); //fields = ListUtils.emptyIfNull(classNode.fields); //methods = ListUtils.emptyIfNull(classNode.methods); final List<FieldNode> fieldNodes = ListUtils.emptyIfNull(classNode.fields); fields = new LinkedHashMap<>(hashMapInitialCapacity(fieldNodes.size())); for (FieldNode fieldNode : fieldNodes) { final FieldCode fieldCode = new FieldCode(fieldNode); fields.put(fieldCode.name, fieldCode); } final List<MethodNode> methodNodes = ListUtils.emptyIfNull(classNode.methods); methods = new ArrayList<>(arrayListInitialCapacity(methodNodes.size())); methodMap = new LinkedHashMap<>(hashMapInitialCapacity(methodNodes.size() * 2)); for (MethodNode methodNode : methodNodes) { final MethodCode methodCode = new MethodCode(this, methodNode); methods.add(methodCode); methodMap.put(methodCode.nameDesc, methodCode); if (!methodMap.containsKey(methodCode.name)) { methodMap.put(methodCode.name, methodCode); } } variableType = VariableType.valueOf(name); isInterface = (access & Opcodes.ACC_INTERFACE) != 0; isSuper = (access & Opcodes.ACC_SUPER) != 0; isAbstract = (access & Opcodes.ACC_ABSTRACT) != 0; isV1_6 = (version & Opcodes.V1_6) != 0; isV1_8 = (version & Opcodes.V1_8) != 0; simpleName = getSimpleName(); }
Example 5
Source File: ClassCode.java From nuls with MIT License | 4 votes |
public ClassCode(ClassNode classNode) { version = classNode.version; access = classNode.access; name = classNode.name; signature = classNode.signature; superName = classNode.superName; interfaces = ListUtils.emptyIfNull(classNode.interfaces); sourceFile = classNode.sourceFile; sourceDebug = classNode.sourceDebug; module = classNode.module; outerClass = classNode.outerClass; outerMethod = classNode.outerMethod; outerMethodDesc = classNode.outerMethodDesc; visibleAnnotations = ListUtils.emptyIfNull(classNode.visibleAnnotations); invisibleAnnotations = ListUtils.emptyIfNull(classNode.invisibleAnnotations); visibleTypeAnnotations = ListUtils.emptyIfNull(classNode.visibleTypeAnnotations); invisibleTypeAnnotations = ListUtils.emptyIfNull(classNode.invisibleTypeAnnotations); attrs = ListUtils.emptyIfNull(classNode.attrs); innerClasses = ListUtils.emptyIfNull(classNode.innerClasses); nestHostClassExperimental = classNode.nestHostClassExperimental; nestMembersExperimental = ListUtils.emptyIfNull(classNode.nestMembersExperimental); //fields = ListUtils.emptyIfNull(classNode.fields); //methods = ListUtils.emptyIfNull(classNode.methods); final List<FieldNode> fieldNodes = ListUtils.emptyIfNull(classNode.fields); fields = new LinkedHashMap<>(hashMapInitialCapacity(fieldNodes.size())); for (FieldNode fieldNode : fieldNodes) { final FieldCode fieldCode = new FieldCode(fieldNode); fields.put(fieldCode.name, fieldCode); } final List<MethodNode> methodNodes = ListUtils.emptyIfNull(classNode.methods); methods = new ArrayList<>(arrayListInitialCapacity(methodNodes.size())); methodMap = new LinkedHashMap<>(hashMapInitialCapacity(methodNodes.size() * 2)); for (MethodNode methodNode : methodNodes) { final MethodCode methodCode = new MethodCode(this, methodNode); methods.add(methodCode); methodMap.put(methodCode.nameDesc, methodCode); if (!methodMap.containsKey(methodCode.name)) { methodMap.put(methodCode.name, methodCode); } } variableType = VariableType.valueOf(name); isInterface = (access & Opcodes.ACC_INTERFACE) != 0; isSuper = (access & Opcodes.ACC_SUPER) != 0; isAbstract = (access & Opcodes.ACC_ABSTRACT) != 0; isV1_6 = (version & Opcodes.V1_6) != 0; isV1_8 = (version & Opcodes.V1_8) != 0; simpleName = getSimpleName(); }
Example 6
Source File: ASMifier.java From JByteMod-Beta with GNU General Public License v2.0 | 4 votes |
@Override public void visit(final int version, final int access, final String name, final String signature, final String superName, final String[] interfaces) { String simpleName; if (name == null) { simpleName = "module-info"; } else { int n = name.lastIndexOf('/'); if (n == -1) { simpleName = name; } else { text.add("package asm." + name.substring(0, n).replace('/', '.') + ";\n"); simpleName = name.substring(n + 1).replace('-', '_'); } } text.add("import java.util.*;\n"); text.add("import org.objectweb.asm.*;\n"); text.add("public class " + simpleName + "Dump implements Opcodes {\n\n"); text.add("public static byte[] dump () throws Exception {\n\n"); text.add("ClassWriter cw = new ClassWriter(0);\n"); text.add("FieldVisitor fv;\n"); text.add("MethodVisitor mv;\n"); text.add("AnnotationVisitor av0;\n\n"); buf.setLength(0); buf.append("cw.visit("); switch (version) { case Opcodes.V1_1: buf.append("V1_1"); break; case Opcodes.V1_2: buf.append("V1_2"); break; case Opcodes.V1_3: buf.append("V1_3"); break; case Opcodes.V1_4: buf.append("V1_4"); break; case Opcodes.V1_5: buf.append("V1_5"); break; case Opcodes.V1_6: buf.append("V1_6"); break; case Opcodes.V1_7: buf.append("V1_7"); break; case Opcodes.V1_8: buf.append("V1_8"); break; case Opcodes.V9: buf.append("V9"); break; default: buf.append(version); break; } buf.append(", "); appendAccess(access | ACCESS_CLASS); buf.append(", "); appendConstant(name); buf.append(", "); appendConstant(signature); buf.append(", "); appendConstant(superName); buf.append(", "); if (interfaces != null && interfaces.length > 0) { buf.append("new String[] {"); for (int i = 0; i < interfaces.length; ++i) { buf.append(i == 0 ? " " : ", "); appendConstant(interfaces[i]); } buf.append(" }"); } else { buf.append("null"); } buf.append(");\n\n"); text.add(buf.toString()); }
Example 7
Source File: AbstractASMBackend.java From JAADAS with GNU General Public License v3.0 | 4 votes |
/** * Creates a new ASM backend * @param sc The SootClass that is to be converted into bytecode * @param javaVersion A particular Java version enforced by the user, may be 0 for automatic detection, must not be lower than necessary for all features used */ public AbstractASMBackend(SootClass sc, int javaVersion) { this.sc = sc; int minVersion = getMinJavaVersion(sc); if (javaVersion == 0) javaVersion = Options.java_version_default; if(javaVersion != Options.java_version_default && javaVersion < minVersion){ throw new IllegalArgumentException("Enforced Java version " + translateJavaVersion(javaVersion) + " too low to support required features (" + translateJavaVersion(minVersion) + " required)"); } javaVersion = Math.max(javaVersion, minVersion); switch (javaVersion) { case Options.java_version_1_1: this.javaVersion = Opcodes.V1_1; break; case Options.java_version_1_2: this.javaVersion = Opcodes.V1_2; break; case Options.java_version_1_3: this.javaVersion = Opcodes.V1_3; break; case Options.java_version_1_4: this.javaVersion = Opcodes.V1_4; break; case Options.java_version_1_5: this.javaVersion = Opcodes.V1_5; break; case Options.java_version_1_6: this.javaVersion = Opcodes.V1_6; break; case Options.java_version_1_7: this.javaVersion = Opcodes.V1_7; break; case Options.java_version_1_8: this.javaVersion = Opcodes.V1_8; break; } }
Example 8
Source File: RetrolambdaPathConfig.java From RxJava2-Java6 with Apache License 2.0 | 4 votes |
@Override public int getBytecodeVersion() { return Opcodes.V1_6; }
Example 9
Source File: ClassNodeImpl.java From jphp with Apache License 2.0 | 4 votes |
public ClassNodeImpl() { super(Opcodes.ASM5); version = Opcodes.V1_6; // todo: available to switch this value this.interfaces = new ArrayList(); this.visibleAnnotations = new ArrayList(); }