Could someone take another look at my submitted bug regarding class names?
Archie Cobbs
archie.cobbs at gmail.com
Sun Feb 19 20:35:43 UTC 2023
On Sun, Feb 19, 2023 at 5:56 AM David Alayachew <davidalayachew at gmail.com>
wrote:
> I have seen a lot of recent discussions about class names and how the
> compiler should generate them (or fail with an error). Seeing that, I
> wanted to query the group and see if anyone has the bandwidth to look at
> this and give some insight.
>
> https://bugs.openjdk.org/browse/JDK-8287885
>
This is not just a problem for inner classes and not just for Windows. I
can reproduce this on my Macbook (which has case-preserving but
case-insensitive filesystem by default) as well:
$ cat a/Foo.java
public class Foo {
public static void main(String[] args) {
System.out.println("Foo");
}
}
$ cat b/FOO.java
public class FOO {
public static void main(String[] args) {
System.out.println("FOO");
}
}
$ javac -d classes {a,b}/*.java
$ ls classes/
Foo.class
$ java -cp classes Foo
Error: Could not find or load main class Foo
Caused by: java.lang.NoClassDefFoundError: FOO (wrong name: Foo)
As the example above shows, just fixing the problem for inner class names
would only be a partial fix.
And of course, this is not just a problem for the compiler, but also the
runtime... i.e., you can't load both Foo.class and FOO.class from the same
directory. But (in contrast to compilation) that problem you can easily
address by putting your classes into a JAR file, etc.
So just brainstorming here... what would it take to fix this?
One could imagine adding a flag like "-dzip classes.zip" which would write
the classes to a ZIP file instead of the filesystem.
So fixing this is do-able but not trivial.. it would take some work to e.g.
create a ZIP file implementation of JavacFileManager, etc.
-Archie
--
Archie L. Cobbs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/compiler-dev/attachments/20230219/4d169956/attachment.htm>
More information about the compiler-dev
mailing list