eclipse中的java instrumentation jar-manifest.mf中的失败
我正在尝试使用java.lang.instrument.Instrumentation类,该类需要使用'premain'类-可以在上找到一个很好的描述 问题是我已经这样做了,在另一个程序中使用它时遇到了困难。我的班级是这样的:eclipse中的java instrumentation jar-manifest.mf中的失败,java,jar,manifest,instrumentation,Java,Jar,Manifest,Instrumentation,我正在尝试使用java.lang.instrument.Instrumentation类,该类需要使用'premain'类-可以在上找到一个很好的描述 问题是我已经这样做了,在另一个程序中使用它时遇到了困难。我的班级是这样的: public class InstrumentationWrapper { private static final String INSTR_KEY = "test.instrumentation"; private static Instrumentation
public class InstrumentationWrapper {
private static final String INSTR_KEY = "test.instrumentation";
private static Instrumentation instrumentation;
public static void premain(String options, Instrumentation inst) {
Properties props = System.getProperties();
if(props.get(INSTR_KEY) == null)
props.put(INSTR_KEY, inst);
}
public static Instrumentation getInstrumentation() {
if (instrumentation == null) {
instrumentation = (Instrumentation) System.getProperties().get(INSTR_KEY);
}
return instrumentation;
}
public static long getObjectSize(Object o) {
return instrumentation.getObjectSize(o);
}
public static long getSizeOfObjects (Collection<?> col) {
long cumSize = 0;
for (Object o : col) {
cumSize = getObjectSize (o);
}
return cumSize;
}
}
而MANIFEST.MF只是:
$ more src/resources/META-INF/MANIFEST.MF
Manifest-Version: 1.0
Premain-Class: com.testTools.instrumentation.InstrumentationWrapper
在eclipse的启动配置中,我遇到了以下问题
在Z:\workspace\\testTools\instrumentor\target\instrumentator-1.0.jar中找不到Premain类清单属性
选项是-javaagent:${workspace\u loc:instrumentator}\target\instrumentator-1.0.jar
我真的不确定如何才能让它工作-我真正需要做的是有一个测试线束,让我看看阵列的内存足迹。有什么想法吗?我没有什么想法,但如果您想进一步检查,可以编写一个快速类,使用java.util.Jar.JarFile
打开Jar文件,并通过编程检查清单。这将表明问题是否以某种方式存在于您编写清单的方式中(可能是错误位置的空格或其他内容),或者是加载的方式中(可能是premain类的规范中存在拼写错误?)
$ more src/resources/META-INF/MANIFEST.MF
Manifest-Version: 1.0
Premain-Class: com.testTools.instrumentation.InstrumentationWrapper