Review Request: JDK-8174694: improve error message shown when main class can't be loaded
Kumar Srinivasan
kumar.x.srinivasan at oracle.com
Wed Feb 15 19:06:44 UTC 2017
On 2/15/2017 10:39 AM, Alan Bateman wrote:
> On 15/02/2017 17:21, Vicente Romero wrote:
>
>> The simplest reproductor for this issue is:
>>
>> ------------------------------------------------------------------------------------------------
>>
>> public class A extends B {
>> public static void main(String... args) {}
>> }
>> ------------------------------------------------------------------------------------------------
>>
>> class B {}
>> ------------------------------------------------------------------------------------------------
>>
>>
>> $javac -d out A.java B.java
>> $rm out/B.class
>>
>> before this patch this command:
>> $java -cp out A
>>
>> produces this output
>> Error: Could not find or load main class A
>>
>> with the current patch, the output produced is:
>> Error: Could not find or load main class A
>> because class B is not defined.
>>
>> if while loading the main class ClassNotFoundException is produced
>> then the second part of the message will be: "because class Foo is
>> not defined."
>> if NoClassDefFoundError is produced then it will be: "because class
>> Foo is not defined"
> It's good that "B" is shown in the output but "because class B is not
> defined" looks very strange to me. Have you consider something more
> useful like:
>
> Error: Could not find or load main class A
> Caused by: java.lang.NoClassDefFoundError: B
Yes this will also solve the translation issue thus we can go back to
one property.
Kumar
>
> -Alan
>
>
More information about the core-libs-dev
mailing list