List of usage examples for org.objectweb.asm Opcodes V1_8
int V1_8
To view the source code for org.objectweb.asm Opcodes V1_8.
Click Source Link
From source file:br.usp.each.saeg.badua.core.internal.ContentTypeDetector.java
License:Open Source License
private static int determineType(final InputStream in) throws IOException { final int header = readInt(in); switch (header) { case ZIPFILE: return ZIPFILE; case PACK200FILE: return PACK200FILE; case CLASSFILE: // also verify version to distinguish from Mach Object files: switch (readInt(in)) { case Opcodes.V1_1: case Opcodes.V1_2: case Opcodes.V1_3: case Opcodes.V1_4: case Opcodes.V1_5: case Opcodes.V1_6: case Opcodes.V1_7: case Opcodes.V1_8: return CLASSFILE; }/*from w w w .jav a2 s .c o m*/ } if ((header & 0xffff0000) == GZFILE) { return GZFILE; } return UNKNOWN; }
From source file:com.android.build.gradle.shrinker.parser.ProguardFlags.java
License:Apache License
public void target(@NonNull String target) { int version;/* w w w . j a v a2 s. c o m*/ switch (target) { case "8": case "1.8": version = Opcodes.V1_8; break; case "7": case "1.7": version = Opcodes.V1_7; break; case "6": case "1.6": version = Opcodes.V1_6; break; case "5": case "1.5": version = Opcodes.V1_5; break; case "1.4": version = Opcodes.V1_4; break; case "1.3": version = Opcodes.V1_3; break; case "1.2": version = Opcodes.V1_2; break; case "1.1": version = Opcodes.V1_1; break; default: throw new AssertionError("Unknown target " + target); } this.bytecodeVersion = new BytecodeVersion(version); }
From source file:com.asakusafw.dag.compiler.codegen.AsmUtil.java
License:Apache License
/** * Creates a new {@link ClassWriter}./*from w w w. j a v a2 s . co m*/ * @param aClass the target class * @param superClass the super class * @param interfaces the interface types * @return the created class writer */ public static ClassWriter newWriter(ClassDescription aClass, Class<?> superClass, Class<?>... interfaces) { Arguments.require(superClass.isInterface() == false); Lang.forEach(interfaces, c -> Arguments.require(c.isInterface())); ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); writer.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC, aClass.getInternalName(), null, typeOf(superClass).getInternalName(), Stream.of(interfaces).map(c -> typeOf(c).getInternalName()).toArray(String[]::new)); return writer; }
From source file:com.facebook.buck.jvm.java.abi.AbiFilteringClassVisitorTest.java
License:Apache License
private static void visitClass(ClassVisitor cv, String name) { cv.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC, name, null, "java/lang/Object", null); }
From source file:com.facebook.buck.jvm.java.abi.ClassVisitorDriverFromElement.java
License:Apache License
/** Gets the class file version corresponding to the given source version constant. */ private 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://from w ww .jav a 2 s . c om throw new IllegalArgumentException(String.format("Unexpected source version: %s", version)); } }
From source file:com.facebook.buck.jvm.java.abi.SourceVersionUtils.java
License:Apache License
/** 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:/*w w w. j av a 2s.c o m*/ throw new IllegalArgumentException(String.format("Unexpected source version: %s", version)); } }
From source file:com.google.gwt.dev.shell.rewrite.HostedModeClassRewriter.java
License:Apache License
/** * Performs rewriting transformations on a class. * * @param typeOracle a typeOracle modeling the user classes * @param className the name of the class * @param classBytes the bytes of the class * @param anonymousClassMap a map between the anonymous class names of java * compiler used to compile code and jdt. Emma-specific. *//*from www.j a va2 s. c om*/ public byte[] rewrite(TypeOracle typeOracle, String className, byte[] classBytes, Map<String, String> anonymousClassMap) { Event classBytesRewriteEvent = SpeedTracerLogger.start(DevModeEventType.CLASS_BYTES_REWRITE, "Class Name", className); String desc = toDescriptor(className); assert (!jsoIntfDescs.contains(desc)); // The ASM model is to chain a bunch of visitors together. ClassWriter writer = new ClassWriter(0); ClassVisitor v = writer; // v = new CheckClassAdapter(v); // v = new TraceClassVisitor(v, new PrintWriter(System.out)); v = new UseMirroredClasses(v, className); v = new RewriteSingleJsoImplDispatches(v, typeOracle, jsoData); v = new RewriteRefsToJsoClasses(v, jsoIntfDescs, mapper); if (jsoImplDescs.contains(desc)) { v = WriteJsoImpl.create(v, desc, jsoIntfDescs, mapper, jsoData); } v = new RewriteJsniMethods(v, anonymousClassMap); if (Double.parseDouble(System.getProperty("java.class.version")) < Opcodes.V1_8) { // TODO(cromwellian) implement Retrolambda? v = new ForceClassVersion15(v); } new ClassReader(classBytes).accept(v, 0); classBytesRewriteEvent.end(); return writer.toByteArray(); }
From source file:de.thetaphi.forbiddenapis.AsmUtils.java
License:Apache License
/** Utility method to load class files of Java 9 by patching them, so ASM can read them. */ public static ClassReader readAndPatchClass(InputStream in) throws IOException { final byte[] b = new byte[8]; final PushbackInputStream pbin = new PushbackInputStream(in, b.length); for (int upto = 0; upto < b.length;) { final int read = pbin.read(b, upto, b.length - upto); if (read == -1) throw new EOFException("Not enough bytes available to read header of class file."); upto += read;// w w w .j a v a 2 s.co m } patchClassMajorVersion(b, Opcodes.V1_8 + 1, Opcodes.V1_8); pbin.unread(b); return new ClassReader(pbin); }
From source file:org.apache.aries.proxy.impl.ProxyUtils.java
License:Apache License
/** * Get the java version to be woven at./*w ww . j ava 2s.c o m*/ * @return */ public static int getWeavingJavaVersion() { if (weavingJavaVersion == -1) { //In order to avoid an inconsistent stack error the version of the woven byte code needs to match //the level of byte codes in the original class switch (JAVA_CLASS_VERSION) { case Opcodes.V1_8: LOGGER.debug("Weaving to Java 8"); weavingJavaVersion = Opcodes.V1_8; break; case Opcodes.V1_7: LOGGER.debug("Weaving to Java 7"); weavingJavaVersion = Opcodes.V1_7; break; case Opcodes.V1_6: LOGGER.debug("Weaving to Java 6"); weavingJavaVersion = Opcodes.V1_6; break; case Opcodes.V1_5: LOGGER.debug("Weaving to Java 5"); weavingJavaVersion = Opcodes.V1_5; break; default: //aries should work with Java 5 or above - also will highlight when a higher level (and unsupported) level of Java is released throw new IllegalArgumentException("Invalid Java version " + JAVA_CLASS_VERSION); } } return weavingJavaVersion; }
From source file:org.codehaus.groovy.classgen.asm.WriterController.java
License:Apache License
private static int chooseBytecodeVersion(final boolean invokedynamic, final boolean previewFeatures, final String targetBytecode) { Integer bytecodeVersion = CompilerConfiguration.JDK_TO_BYTECODE_VERSION_MAP.get(targetBytecode); if (invokedynamic && bytecodeVersion < Opcodes.V1_8) { return Opcodes.V1_8; } else {//from ww w . ja va 2 s . c o m if (null != bytecodeVersion) { return previewFeatures ? bytecodeVersion | Opcodes.V_PREVIEW : bytecodeVersion; } } throw new GroovyBugError("Bytecode version [" + targetBytecode + "] is not supported by the compiler"); }