I get error when I use Xbootclasspath, what should I do ?
Instrumenting with Xbootclasspath can lead to errors if the right jar files are not passed to the java command after weaving. For example, one may see the following error message when running something with Xbootclasspath:
Error occurred during initialization of VM java.lang.NoSuchMethodError: sun.misc.JavaLangAccess.registerShutdownHook(ILjava/lang/Runnable;)V at java.io.Console.<clinit>(Console.java:493) at sun.misc.Unsafe.ensureClassInitialized(Native Method) at sun.misc.SharedSecrets.getJavaIOAccess(SharedSecrets.java:93) at java.lang.System.initializeSystemClass(System.java:1089)
The minimum necessary (for JDK 220.127.116.11 on a Linux OS) is -Xbootclasspath/p:directoryWithInstrumentedJRE:/usr/lib/jvm/java-6-sun-18.104.22.168/jre/lib/rt.jar
I get "Code size too big" error when using AspecJ Compiler, what should I do?
In some extreme cases when you need to monitor classes with huge methods or the intended pointcuts are very dense in some method, you may encounter some error while using standard AspectJ compiler toweave code; such as:
/YourBigClass.java [error] problem generatingThis kind of error is caused by Java's 64-KB maximum method size constraint. If a method of the monitored class has already been very big, then after inserting the advices at the pointcuts, it may violate the 64-KB-constraint. To address this issue, we provide a patch for the standard AspectJ source code to solve this problem quickly. Please follow the instructions below to install the patch (Please backup your AspectJ before applying the patch).
method YourBigClass.bigMethod: Code size too big: 65613.
Prerequisites for using the patch
- AspectJ source code
- If you have not checked out the source code of AspectJ, you can go to here to check it out.
- If you have not installed the program ant yet, then go to here to download and install the latest ant program.
- Go to your local AspectJ git repository, and checkout the commit "Fix 443355: interface super references" by executing the command below (You may need to pull to get the latest update before you can perform the operation below):
git checkout dddd1236cd21982a07f887ff7fa5d484ebc3b86c
- Download "stdAJC_dddd123.patch" from here, and place it inside the above AspectJ repository's top level.
- Apply the patch by executing:
git apply --whitespace=nowarn stdAJC_dddd123.patch
- Build the AspectJ project using ant. You can execute the command
antat the top level of the AspectJ's repository.
- Deploy the AspectJ's libraries. If the previous step is successful, there will be a new folder called aj-build appearing at the top level of the repository. Add all the jar files in <path-to-aspectj-repository>/aj-build/dist/tools/lib to your AspectJ compiler's CLASSPATH.
After generating the new AspectJ libraries and deploying them, your AspectJ compiler should be able to handle the classes with huge methods now.