8255968: Confusing error message for inaccessible constructor

Reviewed-by: mcimadamore
This commit is contained in:
Guoxiong Li 2020-12-01 21:06:06 +00:00 committed by Maurizio Cimadamore
parent c5046ca5b3
commit 29d90b952c
31 changed files with 715 additions and 3 deletions

View file

@ -1583,9 +1583,23 @@ public class Resolve {
currentResolutionContext.addApplicableCandidate(sym, mt);
} catch (InapplicableMethodException ex) {
currentResolutionContext.addInapplicableCandidate(sym, ex.getDiagnostic());
// Currently, an InapplicableMethodException occurs.
// If bestSoFar.kind was ABSENT_MTH, return an InapplicableSymbolError(kind is WRONG_MTH).
// If bestSoFar.kind was HIDDEN(AccessError)/WRONG_MTH/WRONG_MTHS, return an InapplicableSymbolsError(kind is WRONG_MTHS).
// See JDK-8255968 for more information.
switch (bestSoFar.kind) {
case ABSENT_MTH:
return new InapplicableSymbolError(currentResolutionContext);
case HIDDEN:
if (bestSoFar instanceof AccessError) {
// Add the JCDiagnostic of previous AccessError to the currentResolutionContext
// and construct InapplicableSymbolsError.
// Intentionally fallthrough.
currentResolutionContext.addInapplicableCandidate(((AccessError) bestSoFar).sym,
((AccessError) bestSoFar).getDiagnostic(JCDiagnostic.DiagnosticType.FRAGMENT, null, null, site, null, argtypes, typeargtypes));
} else {
return bestSoFar;
}
case WRONG_MTH:
bestSoFar = new InapplicableSymbolsError(currentResolutionContext);
default:
@ -1593,9 +1607,31 @@ public class Resolve {
}
}
if (!isAccessible(env, site, sym)) {
return (bestSoFar.kind == ABSENT_MTH)
? new AccessError(env, site, sym)
: bestSoFar;
AccessError curAccessError = new AccessError(env, site, sym);
JCDiagnostic curDiagnostic = curAccessError.getDiagnostic(JCDiagnostic.DiagnosticType.FRAGMENT, null, null, site, null, argtypes, typeargtypes);
// Currently, an AccessError occurs.
// If bestSoFar.kind was ABSENT_MTH, return an AccessError(kind is HIDDEN).
// If bestSoFar.kind was HIDDEN(AccessError), WRONG_MTH, WRONG_MTHS, return an InapplicableSymbolsError(kind is WRONG_MTHS).
// See JDK-8255968 for more information.
if (bestSoFar.kind == ABSENT_MTH) {
bestSoFar = curAccessError;
} else if (bestSoFar.kind == WRONG_MTH) {
// Add the JCDiagnostic of current AccessError to the currentResolutionContext
// and construct InapplicableSymbolsError.
currentResolutionContext.addInapplicableCandidate(sym, curDiagnostic);
bestSoFar = new InapplicableSymbolsError(currentResolutionContext);
} else if (bestSoFar.kind == WRONG_MTHS) {
// Add the JCDiagnostic of current AccessError to the currentResolutionContext
currentResolutionContext.addInapplicableCandidate(sym, curDiagnostic);
} else if (bestSoFar.kind == HIDDEN && bestSoFar instanceof AccessError) {
// Add the JCDiagnostics of previous and current AccessError to the currentResolutionContext
// and construct InapplicableSymbolsError.
currentResolutionContext.addInapplicableCandidate(((AccessError) bestSoFar).sym,
((AccessError) bestSoFar).getDiagnostic(JCDiagnostic.DiagnosticType.FRAGMENT, null, null, site, null, argtypes, typeargtypes));
currentResolutionContext.addInapplicableCandidate(sym, curDiagnostic);
bestSoFar = new InapplicableSymbolsError(currentResolutionContext);
}
return bestSoFar;
}
return (bestSoFar.kind.isResolutionError() && bestSoFar.kind != AMBIGUOUS)
? sym

View file

@ -0,0 +1,37 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8255968
* @summary Confusing error message for inaccessible constructor
* @run compile/fail/ref=T8255968_1.out -XDrawDiagnostics T8255968_1.java
*/
class T8255968_1 {
T8255968_1_Test c = new T8255968_1_Test(0);
}
class T8255968_1_Test {
private T8255968_1_Test(int x) {}
}

View file

@ -0,0 +1,2 @@
T8255968_1.java:32:25: compiler.err.report.access: T8255968_1_Test(int), private, T8255968_1_Test
1 error

View file

@ -0,0 +1,41 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8255968
* @summary Confusing error message for inaccessible constructor
* @run compile/fail/ref=T8255968_10.out -XDrawDiagnostics T8255968_10.java
*/
class T8255968_10 {
T8255968_10_TestMethodReference c = T8255968_10_Test::new;
}
interface T8255968_10_TestMethodReference {
T8255968_10_Test create(int x);
}
class T8255968_10_Test {
private T8255968_10_Test(int x) {}
}

View file

@ -0,0 +1,2 @@
T8255968_10.java:32:41: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.report.access: T8255968_10_Test(int), private, T8255968_10_Test))
1 error

View file

@ -0,0 +1,41 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8255968
* @summary Confusing error message for inaccessible constructor
* @run compile/fail/ref=T8255968_11.out -XDrawDiagnostics T8255968_11.java
*/
class T8255968_11 {
T8255968_11_TestMethodReference c = T8255968_11_Test::new;
}
interface T8255968_11_TestMethodReference {
T8255968_11_Test create(int x);
}
class T8255968_11_Test {
T8255968_11_Test(String x) {} // If this method is private, compiler will output the same error message.
}

View file

@ -0,0 +1,2 @@
T8255968_11.java:32:41: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbol: kindname.constructor, T8255968_11_Test, java.lang.String, int, kindname.class, T8255968_11_Test, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))))
1 error

View file

@ -0,0 +1,42 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8255968
* @summary Confusing error message for inaccessible constructor
* @run compile/fail/ref=T8255968_12.out -XDrawDiagnostics T8255968_12.java
*/
class T8255968_12 {
T8255968_12_TestMethodReference c = T8255968_12_Test::new;
}
interface T8255968_12_TestMethodReference {
T8255968_12_Test create(int x);
}
class T8255968_12_Test {
private T8255968_12_Test(int x) {} // This method is not at the end.
T8255968_12_Test(String x) {} // If this method is private, compiler will output the same error message.
}

View file

@ -0,0 +1,2 @@
T8255968_12.java:32:41: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbols: kindname.constructor, T8255968_12_Test, int,{(compiler.misc.inapplicable.method: kindname.constructor, T8255968_12_Test, T8255968_12_Test(int), (compiler.misc.report.access: T8255968_12_Test(int), private, T8255968_12_Test)),(compiler.misc.inapplicable.method: kindname.constructor, T8255968_12_Test, T8255968_12_Test(java.lang.String), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String)))}))
1 error

View file

@ -0,0 +1,42 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8255968
* @summary Confusing error message for inaccessible constructor
* @run compile/fail/ref=T8255968_13.out -XDrawDiagnostics T8255968_13.java
*/
class T8255968_13 {
T8255968_13_TestMethodReference c = T8255968_13_Test::new;
}
interface T8255968_13_TestMethodReference {
T8255968_13_Test create(int x);
}
class T8255968_13_Test {
T8255968_13_Test(String x) {} // If this method is private, compiler will output the same error message.
private T8255968_13_Test(int x) {} // This method is at the end.
}

View file

@ -0,0 +1,2 @@
T8255968_13.java:32:41: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbols: kindname.constructor, T8255968_13_Test, int,{(compiler.misc.inapplicable.method: kindname.constructor, T8255968_13_Test, T8255968_13_Test(int), (compiler.misc.report.access: T8255968_13_Test(int), private, T8255968_13_Test)),(compiler.misc.inapplicable.method: kindname.constructor, T8255968_13_Test, T8255968_13_Test(java.lang.String), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String)))}))
1 error

View file

@ -0,0 +1,43 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8255968
* @summary Confusing error message for inaccessible constructor
* @run compile/fail/ref=T8255968_14.out -XDrawDiagnostics T8255968_14.java
*/
class T8255968_14 {
T8255968_14_TestMethodReference c = T8255968_14_Test::new;
}
interface T8255968_14_TestMethodReference {
T8255968_14_Test create(int x);
}
class T8255968_14_Test {
private T8255968_14_Test(int x) {} // This method is not at the end.
T8255968_14_Test(String x) {} // If this method is private, compiler will output the same error message.
private T8255968_14_Test(int[] x) {}
}

View file

@ -0,0 +1,2 @@
T8255968_14.java:32:41: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbols: kindname.constructor, T8255968_14_Test, int,{(compiler.misc.inapplicable.method: kindname.constructor, T8255968_14_Test, T8255968_14_Test(int), (compiler.misc.report.access: T8255968_14_Test(int), private, T8255968_14_Test)),(compiler.misc.inapplicable.method: kindname.constructor, T8255968_14_Test, T8255968_14_Test(java.lang.String), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))),(compiler.misc.inapplicable.method: kindname.constructor, T8255968_14_Test, T8255968_14_Test(int[]), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, int[])))}))
1 error

View file

@ -0,0 +1,43 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8255968
* @summary Confusing error message for inaccessible constructor
* @run compile/fail/ref=T8255968_15.out -XDrawDiagnostics T8255968_15.java
*/
class T8255968_15 {
T8255968_15_TestMethodReference c = T8255968_15_Test::new;
}
interface T8255968_15_TestMethodReference {
T8255968_15_Test create(int x);
}
class T8255968_15_Test {
T8255968_15_Test(String x) {} // If this method is private, compiler will output the same error message.
private T8255968_15_Test(int x) {} // This method is not at the end.
private T8255968_15_Test(int[] x) {}
}

View file

@ -0,0 +1,2 @@
T8255968_15.java:32:41: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbols: kindname.constructor, T8255968_15_Test, int,{(compiler.misc.inapplicable.method: kindname.constructor, T8255968_15_Test, T8255968_15_Test(java.lang.String), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))),(compiler.misc.inapplicable.method: kindname.constructor, T8255968_15_Test, T8255968_15_Test(int), (compiler.misc.report.access: T8255968_15_Test(int), private, T8255968_15_Test)),(compiler.misc.inapplicable.method: kindname.constructor, T8255968_15_Test, T8255968_15_Test(int[]), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, int[])))}))
1 error

View file

@ -0,0 +1,43 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8255968
* @summary Confusing error message for inaccessible constructor
* @run compile/fail/ref=T8255968_16.out -XDrawDiagnostics T8255968_16.java
*/
class T8255968_16 {
T8255968_16_TestMethodReference c = T8255968_16_Test::new;
}
interface T8255968_16_TestMethodReference {
T8255968_16_Test create(int x);
}
class T8255968_16_Test {
T8255968_16_Test(String x) {} // If this method is private, compiler will output the same error message.
private T8255968_16_Test(int[] x) {}
private T8255968_16_Test(int x) {} // This method is at the end.
}

View file

@ -0,0 +1,2 @@
T8255968_16.java:32:41: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.apply.symbols: kindname.constructor, T8255968_16_Test, int,{(compiler.misc.inapplicable.method: kindname.constructor, T8255968_16_Test, T8255968_16_Test(java.lang.String), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))),(compiler.misc.inapplicable.method: kindname.constructor, T8255968_16_Test, T8255968_16_Test(int), (compiler.misc.report.access: T8255968_16_Test(int), private, T8255968_16_Test)),(compiler.misc.inapplicable.method: kindname.constructor, T8255968_16_Test, T8255968_16_Test(int[]), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, int[])))}))
1 error

View file

@ -0,0 +1,37 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8255968
* @summary Confusing error message for inaccessible constructor
* @run compile/fail/ref=T8255968_2.out -XDrawDiagnostics T8255968_2.java
*/
class T8255968_2 {
T8255968_2_Test c = new T8255968_2_Test(0);
}
class T8255968_2_Test {
T8255968_2_Test(String x) {} // If this method is private, compiler will output the same error message.
}

View file

@ -0,0 +1,2 @@
T8255968_2.java:32:25: compiler.err.cant.apply.symbol: kindname.constructor, T8255968_2_Test, java.lang.String, int, kindname.class, T8255968_2_Test, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))
1 error

View file

@ -0,0 +1,38 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8255968
* @summary Confusing error message for inaccessible constructor
* @run compile/fail/ref=T8255968_3.out -XDrawDiagnostics T8255968_3.java
*/
class T8255968_3 {
T8255968_3_Test c = new T8255968_3_Test(0);
}
class T8255968_3_Test {
private T8255968_3_Test(int x) {} // This method is not at the end.
T8255968_3_Test(String x) {} // If this method is private, compiler will output the same error message.
}

View file

@ -0,0 +1,2 @@
T8255968_3.java:32:25: compiler.err.cant.apply.symbols: kindname.constructor, T8255968_3_Test, int,{(compiler.misc.inapplicable.method: kindname.constructor, T8255968_3_Test, T8255968_3_Test(int), (compiler.misc.report.access: T8255968_3_Test(int), private, T8255968_3_Test)),(compiler.misc.inapplicable.method: kindname.constructor, T8255968_3_Test, T8255968_3_Test(java.lang.String), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String)))}
1 error

View file

@ -0,0 +1,38 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8255968
* @summary Confusing error message for inaccessible constructor
* @run compile/fail/ref=T8255968_4.out -XDrawDiagnostics T8255968_4.java
*/
class T8255968_4 {
T8255968_4_Test c = new T8255968_4_Test(0);
}
class T8255968_4_Test {
T8255968_4_Test(String x) {} // If this method is private, compiler will output the same error message.
private T8255968_4_Test(int x) {} // This method is at the end.
}

View file

@ -0,0 +1,2 @@
T8255968_4.java:32:25: compiler.err.cant.apply.symbols: kindname.constructor, T8255968_4_Test, int,{(compiler.misc.inapplicable.method: kindname.constructor, T8255968_4_Test, T8255968_4_Test(int), (compiler.misc.report.access: T8255968_4_Test(int), private, T8255968_4_Test)),(compiler.misc.inapplicable.method: kindname.constructor, T8255968_4_Test, T8255968_4_Test(java.lang.String), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String)))}
1 error

View file

@ -0,0 +1,39 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8255968
* @summary Confusing error message for inaccessible constructor
* @run compile/fail/ref=T8255968_5.out -XDrawDiagnostics T8255968_5.java
*/
class T8255968_5 {
T8255968_5_Test c = new T8255968_5_Test(0);
}
class T8255968_5_Test {
private T8255968_5_Test(int x) {} // This method is not at the end.
T8255968_5_Test(String x) {} // If this method is private, compiler will output the same error message.
private T8255968_5_Test(int[] x) {}
}

View file

@ -0,0 +1,2 @@
T8255968_5.java:32:25: compiler.err.cant.apply.symbols: kindname.constructor, T8255968_5_Test, int,{(compiler.misc.inapplicable.method: kindname.constructor, T8255968_5_Test, T8255968_5_Test(int), (compiler.misc.report.access: T8255968_5_Test(int), private, T8255968_5_Test)),(compiler.misc.inapplicable.method: kindname.constructor, T8255968_5_Test, T8255968_5_Test(java.lang.String), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))),(compiler.misc.inapplicable.method: kindname.constructor, T8255968_5_Test, T8255968_5_Test(int[]), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, int[])))}
1 error

View file

@ -0,0 +1,39 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8255968
* @summary Confusing error message for inaccessible constructor
* @run compile/fail/ref=T8255968_6.out -XDrawDiagnostics T8255968_6.java
*/
class T8255968_6 {
T8255968_6_Test c = new T8255968_6_Test(0);
}
class T8255968_6_Test {
T8255968_6_Test(String x) {} // If this method is private, compiler will output the same error message.
private T8255968_6_Test(int x) {} // This method is not at the end.
private T8255968_6_Test(int[] x) {}
}

View file

@ -0,0 +1,2 @@
T8255968_6.java:32:25: compiler.err.cant.apply.symbols: kindname.constructor, T8255968_6_Test, int,{(compiler.misc.inapplicable.method: kindname.constructor, T8255968_6_Test, T8255968_6_Test(java.lang.String), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))),(compiler.misc.inapplicable.method: kindname.constructor, T8255968_6_Test, T8255968_6_Test(int), (compiler.misc.report.access: T8255968_6_Test(int), private, T8255968_6_Test)),(compiler.misc.inapplicable.method: kindname.constructor, T8255968_6_Test, T8255968_6_Test(int[]), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, int[])))}
1 error

View file

@ -0,0 +1,39 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8255968
* @summary Confusing error message for inaccessible constructor
* @run compile/fail/ref=T8255968_7.out -XDrawDiagnostics T8255968_7.java
*/
class T8255968_7 {
T8255968_7_Test c = new T8255968_7_Test(0);
}
class T8255968_7_Test {
T8255968_7_Test(String x) {} // If this method is private, compiler will output the same error message.
private T8255968_7_Test(int[] x) {}
private T8255968_7_Test(int x) {} // This method is at the end.
}

View file

@ -0,0 +1,2 @@
T8255968_7.java:32:25: compiler.err.cant.apply.symbols: kindname.constructor, T8255968_7_Test, int,{(compiler.misc.inapplicable.method: kindname.constructor, T8255968_7_Test, T8255968_7_Test(java.lang.String), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, java.lang.String))),(compiler.misc.inapplicable.method: kindname.constructor, T8255968_7_Test, T8255968_7_Test(int), (compiler.misc.report.access: T8255968_7_Test(int), private, T8255968_7_Test)),(compiler.misc.inapplicable.method: kindname.constructor, T8255968_7_Test, T8255968_7_Test(int[]), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: int, int[])))}
1 error

View file

@ -0,0 +1,45 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8255968
* @summary Confusing error message for inaccessible constructor
* @run compile -XDrawDiagnostics T8255968_8.java
*/
class T8255968_8_Outer {
void m() {}
void m(String s) {}
class T8255968_8_Inner extends T8255968_8_Sup {
void test() {
m();
}
}
}
class T8255968_8_Sup {
private void m(String s) {}
private void m() {}
}

View file

@ -0,0 +1,41 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8255968
* @summary Confusing error message for inaccessible constructor
* @run compile -XDrawDiagnostics T8255968_9.java
*/
class T8255968_9 {
T8255968_9_TestMethodReference c = T8255968_9_Test::new;
}
interface T8255968_9_TestMethodReference {
T8255968_9_Test create(int x);
}
class T8255968_9_Test {
T8255968_9_Test(int x) {}
}