Bug 540570 - Update to ASM 7.0

Change-Id: I4b7087ae71f69988c97c502afa28d59704e62fc8
Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
diff --git a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/core/StratumTests.java b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/core/StratumTests.java
index 157e575..4ad303e 100644
--- a/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/core/StratumTests.java
+++ b/org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/core/StratumTests.java
@@ -48,9 +48,9 @@
 			String[] strata = type.getAvailableStrata();
 			Arrays.sort(strata);
 			String version = ((IJavaDebugTarget)thread.getDebugTarget()).getVersion();
-			// TODO ideally need to check "if 11 or newer"
-			if (version.startsWith("11")) {
-				// as of 2018-11-02 java 11 was not supported by the sourcelookup agent
+			// TODO ideally need to check "if NN or newer"
+			if (version.startsWith("12")) {
+				// as of 2018-11-15 java 12 was not supported by the sourcelookup agent
 				assertEquals("Wrong number of available strata", 1, strata.length);
 				assertEquals("Wrong strata", "Java", strata[0]);
 			} else {
diff --git a/org.eclipse.jdt.launching.javaagent/META-INF/MANIFEST.MF b/org.eclipse.jdt.launching.javaagent/META-INF/MANIFEST.MF
index 12b80cf..e842fc7 100644
--- a/org.eclipse.jdt.launching.javaagent/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.launching.javaagent/META-INF/MANIFEST.MF
@@ -5,7 +5,7 @@
 Bundle-Version: 3.9.0.qualifier
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
-Require-Bundle: org.objectweb.asm;bundle-version="[6.1.1,7.0.0)"
+Require-Bundle: org.objectweb.asm;bundle-version="[7.0.0,7.1.0)"
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Automatic-Module-Name: org.eclipse.jdt.launching.javaagent
diff --git a/org.eclipse.jdt.launching.javaagent/README.md b/org.eclipse.jdt.launching.javaagent/README.md
new file mode 100644
index 0000000..1e7963d
--- /dev/null
+++ b/org.eclipse.jdt.launching.javaagent/README.md
@@ -0,0 +1,14 @@
+## Updating ASM library version
+
+1. Change `org.ow2.asm:asm` version in `pom.xml` file. This defines version of ASM used by the javaagent at runtime and during Maven build on command line.
+2. Change `org.objectweb.asm` bundle-version in `META-INF/MANIFEST.MF`. This defines version of ASM used to compile the javaagent in PDE. **This has no effect on command line Maven build or runtime!**.
+	* Make sure the new version of ASM is part of PDE target platform. You may need to copy ASM jar to the target platform manually as PDE does not download project dependencies automatically.
+3. If adding support for new Java classfile version
+   - Update `ClassfileTransformer#ASM_API` to indicate ASM API version used by the javaagent. This defines what bytecode instructions ASM is able to interpret and process. Classfiles that use unsupported instructions will fail instrumentation and the javaagent will print `Could not instrument class ...` error message to stderr.
+   - Update `ClassfileTransformer#MAX_CLASS_MAJOR` to match maximum java classfile version. The javaagent silently skips instrumentation of classfiles with newer version.
+   - Update `StratumTests#testAvailableStrata` to indicate Java version(s) that are not supported by the javaagent. Typically this is N+1 compared to `ClassfileTransformer#MAX_CLASS_MAJOR`.
+4. Build the javaagent jar file by running `mvn clean package` command from `org.eclipse.jdt.launching.javaagent/` directory. This creates  `org.eclipse.jdt.launching.javaagent/target/javaagent-shaded.jar` jar file, which includes the javaagent and ASM classes. 
+   * Note that ASM classes are _relocated_ to `org.eclipse.jdt.launching.internal.org.objectweb.asm` package to avoid possible conflicts with applicates being debugged.
+5. Copy `javaagent-shaded.jar` to `org.eclipse.jdt.launching/lib` folder. This is the javaagent jar used at runtime.
+6. Run the tests, ideally using all supported java versions.
+7. Commit all changed files to git and submit the changes to Gerrit for review.
diff --git a/org.eclipse.jdt.launching.javaagent/pom.xml b/org.eclipse.jdt.launching.javaagent/pom.xml
index 74756ff..9bf6d4a 100644
--- a/org.eclipse.jdt.launching.javaagent/pom.xml
+++ b/org.eclipse.jdt.launching.javaagent/pom.xml
@@ -20,7 +20,7 @@
     <dependency>
       <groupId>org.ow2.asm</groupId>
       <artifactId>asm</artifactId>
-      <version>6.2.1</version>
+      <version>7.0</version>
     </dependency>
   </dependencies>
 
diff --git a/org.eclipse.jdt.launching.javaagent/src/main/java/org/eclipse/jdt/launching/internal/weaving/ClassfileTransformer.java b/org.eclipse.jdt.launching.javaagent/src/main/java/org/eclipse/jdt/launching/internal/weaving/ClassfileTransformer.java
index 6476bba..58657d1 100644
--- a/org.eclipse.jdt.launching.javaagent/src/main/java/org/eclipse/jdt/launching/internal/weaving/ClassfileTransformer.java
+++ b/org.eclipse.jdt.launching.javaagent/src/main/java/org/eclipse/jdt/launching/internal/weaving/ClassfileTransformer.java
@@ -24,10 +24,10 @@
 	private static final String STRATA_ID = "jdt"; //$NON-NLS-1$
 
 	/** max supported java class format major version, must match {@link #ASM_API} below **/
-	public static final int MAX_CLASS_MAJOR = Opcodes.V10;
+	public static final int MAX_CLASS_MAJOR = Opcodes.V11;
 
 	/** supported ASM API version, must match {@link #MAX_CLASS_MAJOR} above */
-	private static final int ASM_API = Opcodes.ASM6;
+	private static final int ASM_API = Opcodes.ASM7;
 
 	public byte[] transform(byte[] classfileBuffer, final String location) {
 
diff --git a/org.eclipse.jdt.launching/lib/javaagent-shaded.jar b/org.eclipse.jdt.launching/lib/javaagent-shaded.jar
index 1fe2aec..5d06bed 100644
--- a/org.eclipse.jdt.launching/lib/javaagent-shaded.jar
+++ b/org.eclipse.jdt.launching/lib/javaagent-shaded.jar
Binary files differ