Hi Fabio,
The issue I saw during my experiment with automatic instrumentation is that it tends to instrument more methods than necessary.
This can lead to trying to instrument special methods (constructors) and synchronized methods.
In both cases the instrumentation fails with UnableToInstrumentException, like the following:
[quasar] ERROR: Unable to instrument Foo
co.paralleluniverse.fibers.instrument.UnableToInstrumentException: Unable to instrument Foo#bar()V because of synchronized method
at co.paralleluniverse.fibers.instrument.CheckInstrumentationVisitor.visitMethod(CheckInstrumentationVisitor.java:136)
at co.paralleluniverse.asm.ClassReader.b(Unknown Source)
at co.paralleluniverse.asm.ClassReader.accept(Unknown Source)
at co.paralleluniverse.asm.ClassReader.accept(Unknown Source)
at co.paralleluniverse.fibers.instrument.MethodDatabase.checkFileAndClose(MethodDatabase.java:388)
at co.paralleluniverse.fibers.instrument.MethodDatabase.checkClass(MethodDatabase.java:365)
at co.paralleluniverse.fibers.instrument.MethodDatabase.getOrLoadClassEntry(MethodDatabase.java:222)
at co.paralleluniverse.fibers.instrument.MethodDatabase.isMethodSuspendable0(MethodDatabase.java:233)
at co.paralleluniverse.fibers.instrument.MethodDatabase.isMethodSuspendable(MethodDatabase.java:200)
at co.paralleluniverse.fibers.instrument.InstrumentMethod.isSuspendableCall(InstrumentMethod.java:195)
at co.paralleluniverse.fibers.instrument.InstrumentMethod.callsSuspendables(InstrumentMethod.java:161)
at co.paralleluniverse.fibers.instrument.InstrumentClass.visitEnd(InstrumentClass.java:261)
at co.paralleluniverse.asm.ClassReader.accept(Unknown Source)
at co.paralleluniverse.asm.ClassReader.accept(Unknown Source)
at co.paralleluniverse.fibers.instrument.QuasarInstrumentor.instrumentClass(QuasarInstrumentor.java:120)
at co.paralleluniverse.fibers.instrument.QuasarInstrumentor.instrumentClass(QuasarInstrumentor.java:88)
at co.paralleluniverse.fibers.instrument.JavaAgent$Transformer.transform(JavaAgent.java:187)
at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
[quasar] ERROR: Unable to instrument class Foo
co.paralleluniverse.fibers.instrument.UnableToInstrumentException: Unable to instrument Foo#<init>()V because of special method
at co.paralleluniverse.fibers.instrument.InstrumentClass.visitEnd(InstrumentClass.java:263)
at co.paralleluniverse.asm.ClassReader.accept(Unknown Source)
at co.paralleluniverse.asm.ClassReader.accept(Unknown Source)
at co.paralleluniverse.fibers.instrument.QuasarInstrumentor.instrumentClass(QuasarInstrumentor.java:120)
at co.paralleluniverse.fibers.instrument.QuasarInstrumentor.instrumentClass(QuasarInstrumentor.java:88)
at co.paralleluniverse.fibers.instrument.JavaAgent$Transformer.transform(JavaAgent.java:187)
at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
My questions are:
1. Is there a way to manually "terminate" the instrumentation vistors in the aforementioned cases with auto instrumentation enabled.
2. If not, is there any best practices to workaround the instrumentation errors. Or are they benign in nature?
BTW, we are using quasar-core 0.7.5.
Many thanks!
在 2016年5月24日星期二 UTC-4下午8:48:00,Fabio Tudone写道: