-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
warning: auxiliary class CompoundEnumeration in ClassLoader.java should not be accessed from outside its own source file #90
Comments
This warning is shown when accessing a non-public class from a .java file that contains multiple classes. Although it's not recommended, it is possible to declare multiple classes in one .java file. However, only one of those classes can be public: === A.java === public class A { class B { ============ |
Our java.lang.ClassLoader model class references java.lang.CompoundEnumeration which is an auxilary class declared within the java standard class java/lang/ClassLoader.java This includes CompoundEnumeration class within our model class itself, so to prevent our ClassLoader model class from referencing an auxilary class from outside its own source file. This fixes: warning: auxiliary class CompoundEnumeration in ClassLoader.java should not be accessed from outside its own source file Fixes: javapathfinder#90
The current code expects to have java.lang.CompoundEnumeration public standard Java class. But due to changes in the JDK, there seems to have no such public class. In JDK 9/10 for example it is declared in the java/lang/ClassLoader.java itself. Please see the PR. jpf-core/src/classes/modules/java.base/java/lang/ClassLoader.java Lines 102 to 113 in cf154ec
References: |
It seems that this class is a merely utility that allows continuous iteration over all values from an array of enumerations. The class name is probably not important; the essential part lies in the behaviour. Maybe we can rewrite this method to return an instance of Enumeration that contains all values from the arrays resEnum[0] and resEnum[1]? By the way, this Enumeration class is from JDK 1.0, and probably is not used widely anymore; its name is a bit unfortunate as one can confuse it with Enum. This Enumeration class seems to be a less poverful equivalent of Iterator. |
Thanks for the tip. What about this implementation, though it is quite verbose?
|
Well, using
|
java.lang.ClassLoader#getResources in the model class java.lang.ClassLoader references java.lang.CompoundEnumeration which is an auxilary class declared within the java standard class java/lang/ClassLoader.java This adds a new auxilary class named EnumerationAdapter within the model class, as replacement for CompoundEnumeration class, so to prevent our ClassLoader model class from referencing an auxilary class from outside its own source file. This fixes: warning: auxiliary class CompoundEnumeration in ClassLoader.java should not be accessed from outside its own source file Fixes: javapathfinder#90
java.lang.ClassLoader#getResources in the model class java.lang.ClassLoader references java.lang.CompoundEnumeration which is an auxilary class declared within the java standard class java/lang/ClassLoader.java This adds a new auxilary class named EnumerationAdapter within the model class, as replacement for CompoundEnumeration class, so to prevent our ClassLoader model class from referencing an auxilary class from outside its own source file. This fixes: warning: auxiliary class CompoundEnumeration in ClassLoader.java should not be accessed from outside its own source file Fixes: javapathfinder#90
Following compiler warning shows up in the build logs:
Travis log:
https://travis-ci.org/javapathfinder/jpf-core/builds/393023635#L2444-L2446
The text was updated successfully, but these errors were encountered: