IDEA-181303 java.lang.IllegalArgumentException by org.jetbrains.org.objectweb.asm.ClassVisitor while running JUnit tests with latest EAP

This commit is contained in:
Egor Ushakov
2018-02-26 20:12:10 +03:00
parent c2af70a8c6
commit e1683b5f36
5 changed files with 13 additions and 34 deletions
+1
View File
@@ -6,6 +6,7 @@
<element id="directory" name="META-INF">
<element id="file-copy" path="$PROJECT_DIR$/java/debugger/debugger-agent/META-INF/MANIFEST.MF" />
</element>
<element id="extracted-dir" path="$PROJECT_DIR$/java/debugger/debugger-agent/lib/asm-capture.jar" path-in-jar="/" />
</root>
</artifact>
</component>
@@ -7,7 +7,15 @@
</content>
<orderEntry type="jdk" jdkName="IDEA jdk" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="ASM" level="project" />
<orderEntry type="module" module-name="intellij.java.debugger.agent.storage" />
<orderEntry type="module-library">
<library name="asm-capture">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/asm-capture.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
Binary file not shown.
@@ -1,7 +1,7 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.rt.debugger.agent;
import org.jetbrains.org.objectweb.asm.*;
import org.jetbrains.capture.org.objectweb.asm.*;
import java.io.File;
import java.io.FileOutputStream;
@@ -12,7 +12,6 @@ import java.lang.instrument.Instrumentation;
import java.lang.instrument.UnmodifiableClassException;
import java.security.ProtectionDomain;
import java.util.*;
import java.util.jar.JarFile;
/**
* @author egor
@@ -28,26 +27,7 @@ public class CaptureAgent {
public static void premain(String args, Instrumentation instrumentation) {
ourInstrumentation = instrumentation;
try {
String asmPath = readSettings(args);
if (asmPath == null) {
return;
}
try {
instrumentation.appendToSystemClassLoaderSearch(new JarFile(asmPath));
}
catch (Exception e) {
String report = "Capture agent: unable to use the provided asm lib";
try {
Class.forName("org.jetbrains.org.objectweb.asm.MethodVisitor");
System.out.println(report + ", will use asm from the classpath");
}
catch (ClassNotFoundException e1) {
System.out.println(report + ", exiting");
return;
}
}
readSettings(args);
instrumentation.addTransformer(new CaptureTransformer());
@@ -87,7 +67,7 @@ public class CaptureAgent {
System.setProperty(modulesKey, property);
}
private static String readSettings(String path) {
private static void readSettings(String path) {
FileReader reader = null;
try {
reader = new FileReader(path);
@@ -105,12 +85,6 @@ public class CaptureAgent {
boolean deleteSettings = Boolean.parseBoolean(properties.getProperty("deleteSettings", "true"));
String asmPath = properties.getProperty("asm-lib");
if (asmPath == null) {
System.out.println("Capture agent: asm path is not specified, exiting");
return null;
}
Enumeration<?> propNames = properties.propertyNames();
while (propNames.hasMoreElements()) {
String propName = (String)propNames.nextElement();
@@ -126,7 +100,6 @@ public class CaptureAgent {
if (deleteSettings) {
new File(path).delete();
}
return asmPath;
}
catch (IOException e) {
System.out.println("Capture agent: unable to read settings");
@@ -142,7 +115,6 @@ public class CaptureAgent {
}
}
}
return null;
}
private static <T> List<T> getNotNull(List<T> list) {
@@ -52,7 +52,6 @@ import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.org.objectweb.asm.MethodVisitor;
import javax.swing.*;
import java.io.File;
@@ -597,7 +596,6 @@ public class DebuggerManagerImpl extends DebuggerManagerEx implements Persistent
private static String generateAgentSettings() {
Properties properties = new Properties();
properties.setProperty("asm-lib", PathUtil.getJarPathForClass(MethodVisitor.class));
if (Registry.is("debugger.capture.points.agent.debug")) {
properties.setProperty("debug", "true");
}