[BLUEJ-35] Classpath issues in user code
While looking at whether we should have a BProject.getClassPath() method in the extensions API, I noticed the following.
- The core-BlueJ internal classes are visible to user code, both at compile- time and run time. While not an error, this might cause some surprises!
E.g. The following code compiles and runs as part of a BlueJ project: bq. public class CPTest bq. { public String [] f() { return bluej.utility.Utility.splitLines("a\nb"); } }
"Use Library Class" doesn't seem to find the Utility class, but the Code Pad does so typing: System.out.println(bluej.utility.Utility.splitLines("a\nb")[0]); into the Code Pad also works.
- If a user's code references classes from bluejext.jar, BlueJ takes an exception while compiling. E.g. the code (as part of a project): bq. import bluej.extensions.*;
bq. public class SimpleExtension extends Extension { public void startup (BlueJ bluej) {} public boolean isCompatible () { return true; } public String getVersion () { return null; } public String getName () { return null; } public String getDescription () { return null; } public java.net.URL getURL () { return null; } }
causes: bq. Exception in thread "BlueJ compiler thread" java.lang.NoClassDefFoundError: bluej/extensions/Extension at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:620) at java.security.SecureClassLoader.defineClass (SecureClassLoader.java:124) at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) at java.net.URLClassLoader.access$100(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at bluej.pkgmgr.Project.loadClass(Project.java:882) at bluej.pkgmgr.Package.loadClass(Package.java:920) at bluej.pkgmgr.target.ClassTarget.endCompile(ClassTarget.java:762) at bluej.pkgmgr.Package$PackageCompileObserver.endCompile (Package.java:2079) at bluej.compiler.Job.compile(Job.java:57) at bluej.compiler.CompilerThread.run(CompilerThread.java:50)
------- Comment BLUEJ-1 From Ian Utting 2005-10-13 16:45:34 [reply] -------
(Codebase of 13/10/05) There's been some work on classpath handling since I reported this bug, and the situation is now much cleaner. Core-bluej classes are still visible to user code at compile time and run time. They are also now visible through both "Use Library class" and the Codepad. Classes in bluej.extensions.* are now not visible to user code at compile time.
------- Comment BLUEJ-2 From Bruce Quig 2005-11-16 04:41:54 [reply] -------
Things are much cleaner now as mentioned. Question is whether there is a need to do anything further?
Issue metadata
- Issue type: Bug
- Priority: Low
- Fix versions: 3.0.6