h3. Coping with the Boot Class Path
Some projects, such as [MethodHandles], require us to develop Java code and test cases under packages like {{java.dyn}}. Classes in packages under {{java}} cannot be loaded by the normal means of setting {{CLASSPATH}} or using the {{-cp}} flag. The JVM will throw an exception like this:
{noformat:title=what can happen when you develop in java.dyn}
$ java -cp "$mypath" java.dyn.MethodHandleBytecodeTest
Exception in thread "main" java.lang.SecurityException: Prohibited package name: java.dyn
{noformat}
Instead, you must put your classes on the boot class path, as follows:
{noformat:title=successfully running your java.dyn code}
$ java -Xbootclasspath/a:"$mypath" java.dyn.MethodHandleBytecodeTest
invoke toString
invoke mh=java.dyn.hotspot.VMH@15ff48b
...
{noformat}
If you are running [JUnit|http://junit.org], you will also need to place the JAR for JUnit on the boot class path. You can fish the JAR out of your NetBeans distribution (e.g., under {{NetBeans 6.1.app/Contents/Resources/NetBeans/java2/modules/ext}}), or you can download it from [SourceForge|http://sourceforge.net/project/showfiles.php?group_id=15278&package_id=12472].
h3. NetBeans Modifications
In order to run test correctly from inside NetBeans, you have to hack the boot class path. Add the following line to {{nbproject/project.properties}}:
{noformat:title=NetBeans properties hacking boot class path}
run.jvmargs=-Xbootclasspath/a:"${build.classes.dir}:${libs.junit.classpath}"
{noformat}
The quotes are important, since there might be spaces in the path names.
(I would like put the setting in {{build.xml}}, so that it will have the required effect outside of NetBeans. No success with this yet.)
Some projects, such as [MethodHandles], require us to develop Java code and test cases under packages like {{java.dyn}}. Classes in packages under {{java}} cannot be loaded by the normal means of setting {{CLASSPATH}} or using the {{-cp}} flag. The JVM will throw an exception like this:
{noformat:title=what can happen when you develop in java.dyn}
$ java -cp "$mypath" java.dyn.MethodHandleBytecodeTest
Exception in thread "main" java.lang.SecurityException: Prohibited package name: java.dyn
{noformat}
Instead, you must put your classes on the boot class path, as follows:
{noformat:title=successfully running your java.dyn code}
$ java -Xbootclasspath/a:"$mypath" java.dyn.MethodHandleBytecodeTest
invoke toString
invoke mh=java.dyn.hotspot.VMH@15ff48b
...
{noformat}
If you are running [JUnit|http://junit.org], you will also need to place the JAR for JUnit on the boot class path. You can fish the JAR out of your NetBeans distribution (e.g., under {{NetBeans 6.1.app/Contents/Resources/NetBeans/java2/modules/ext}}), or you can download it from [SourceForge|http://sourceforge.net/project/showfiles.php?group_id=15278&package_id=12472].
h3. NetBeans Modifications
In order to run test correctly from inside NetBeans, you have to hack the boot class path. Add the following line to {{nbproject/project.properties}}:
{noformat:title=NetBeans properties hacking boot class path}
run.jvmargs=-Xbootclasspath/a:"${build.classes.dir}:${libs.junit.classpath}"
{noformat}
The quotes are important, since there might be spaces in the path names.
(I would like put the setting in {{build.xml}}, so that it will have the required effect outside of NetBeans. No success with this yet.)