Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 323342

Summary: JavaConventions#validatePackageName(..) allows creation of package whose name begins with "java"
Product: [Eclipse Project] JDT Reporter: Curtis Autery <ceautery>
Component: CoreAssignee: Ayushman Jain <amj87.iitr>
Status: NEW --- QA Contact:
Severity: minor    
Priority: P3 CC: jarthana, markus.kell.r, remy.suen, yatsenko.ihor
Version: 3.7   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
See Also: https://git.eclipse.org/r/151490
https://git.eclipse.org/r/151503
Whiteboard: stalebug

Description Curtis Autery CLA 2010-08-22 20:53:27 EDT
Build Identifier: 20100617-1415

Creating a package whose name starts with "java" does not show any error hints, and a SecurityException is thrown at compile time.


Reproducible: Always

Steps to Reproduce:
This can be duplicated by creating a package named java.test, creating any class file underneath it, and attempting to run. The following error will be thrown:

java.lang.SecurityException: Prohibited package name: java.test
	at java.lang.ClassLoader.preDefineClass(ClassLoader.java:480)
Comment 1 Markus Keller CLA 2010-08-23 06:34:48 EDT
I didn't find anything in the JLS that would disallow a package starting with "java.", and javac also happily compiles such classes. Only java.lang.ClassLoader#defineClass(..) says that a package name must not start with "java.".

Moving to JDT/Core. JavaConventions#validatePackageName(..) should return a warning for such package names. It should not be an error, since the construct is legal and can actually be used for testing purposes (if the classes are loaded via -Xbootclasspath).

package java.test;
public class C {
	public static void main(String[] args) {
		System.out.println("Hello World");
	}
}
Comment 2 Frederic Fusier CLA 2010-08-23 12:50:17 EDT
Ayush, please follow-up, thanks
Comment 3 Eclipse Genie CLA 2019-10-23 10:49:48 EDT
New Gerrit change created: https://git.eclipse.org/r/151490
Comment 4 Eclipse Genie CLA 2019-10-23 17:10:08 EDT
New Gerrit change created: https://git.eclipse.org/r/151503
Comment 5 Ihor Yatsenko CLA 2019-10-24 10:44:55 EDT
@Markus Keller can you please take a look my fix?
Comment 6 Jay Arthanareeswaran CLA 2019-11-13 00:02:53 EST
(In reply to Ihor Yatsenko from comment #5)
> @Markus Keller can you please take a look my fix?

Markus is no longer with the team. I will keep this in the radar but no guarantee yet.
Comment 7 Eclipse Genie CLA 2021-11-03 08:35:50 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.