I'm using ASM to inject code to methods:
@Override
public void visitCode() {
visitMethodInsn(Opcodes.INVOKESTATIC, "sssss/CopyOfsss", "foo", "()V");
super.visitCode();
}
Exception in thread "main" java.lang.NoClassDefFoundError: sssss/CopyOfsss
at java.util.regex.Pattern$Node.match(Pattern.java)
at java.util.regex.Pattern$CharProperty.match(Pattern.java:3345)
at java.util.regex.Pattern$Curly.match0(Pattern.java:3760)
at java.util.regex.Pattern$Curly.match(Pattern.java:3744)
at java.util.regex.Matcher.match(Matcher.java:1127)
at java.util.regex.Matcher.matches(Matcher.java:502)
at sssss.CopyOfsss.main(CopyOfsss.java:26)
please help~
Well, I got my answer. This is because the injected class is loaded by bootstrap class loader, so the injected code can't call methods in "CopyOfsssss". Refer to this article. The solution is adding "-Xbootclasspath/a:/path/yourclass.lib" to the jvm argument. Note the "/a" after "Xbootclasspath" means appending.