RFR: 8255968: Confusing error message for inaccessible constructor [v3]

Guoxiong Li github.com+13688759+lgxbslgx at openjdk.java.net
Wed Nov 25 17:34:57 UTC 2020


On Wed, 25 Nov 2020 13:44:31 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Guoxiong Li has updated the pull request incrementally with three additional commits since the last revision:
>> 
>>  - Change the `Test(String x)` from private to default. Add comments in test cases to improve readability.
>>  - Add corresponding tests for the method reference cases.
>>  - Add comments to state the situations
>
> I left some additional comments on tests. I plan to do some experiments to validate that we are not going to introduce bad regressions.

The old style which is shown below is not good.
class T8255968 {
    Test c = new Test(0);
}

class Test {
    private Test(int x) {}
}

> and that the auxiliary classes defined in these test are, instead, defined as nested classes

I change it to the following style according to the comment. But the compiler compiles it successfully because the outer class can visit private method of its inner class.
class T8255968_1 {
    Test c = new Test(0);

    class Test {
        private Test(int x) {}
    }
}


So I would like to use the following style(don't use nested classes).
class T8255968_1 {
    T8255968Test1 c = new T8255968Test1(0);
}

class T8255968Test1 {
    private T8255968Test1(int x) {}
}

@mcimadamore Do you agree with this style?

-------------

PR: https://git.openjdk.java.net/jdk/pull/1389


More information about the compiler-dev mailing list