--- old/test/tools/javac/TryWithResources/T7022711.java 2015-10-19 06:34:49.599907675 +0300 +++ new/test/tools/javac/TryWithResources/T7022711.java 2015-10-19 06:34:49.515907673 +0300 @@ -9,10 +9,20 @@ class T7022711 { public static void main (String args[]) throws Exception { + // declared resource try (DataInputStream is = new DataInputStream(new FileInputStream("x"))) { while (true) { is.getChar(); // method not found } + } catch (EOFException e) { + } + + // resource as variable + DataInputStream is = new DataInputStream(new FileInputStream("x")); + try (is) { + while (true) { + is.getChar(); // method not found + } } catch (EOFException e) { } } --- old/test/tools/javac/TryWithResources/T7022711.out 2015-10-19 06:34:49.855907683 +0300 +++ new/test/tools/javac/TryWithResources/T7022711.out 2015-10-19 06:34:49.771907681 +0300 @@ -1,2 +1,3 @@ -T7022711.java:14:19: compiler.err.cant.resolve.location.args: kindname.method, getChar, , , (compiler.misc.location.1: kindname.variable, is, java.io.DataInputStream) -1 error +T7022711.java:15:19: compiler.err.cant.resolve.location.args: kindname.method, getChar, , , (compiler.misc.location.1: kindname.variable, is, java.io.DataInputStream) +T7022711.java:24:19: compiler.err.cant.resolve.location.args: kindname.method, getChar, , , (compiler.misc.location.1: kindname.variable, is, java.io.DataInputStream) +2 errors --- old/test/tools/javac/TryWithResources/T7032633.java 2015-10-19 06:34:50.111907691 +0300 +++ new/test/tools/javac/TryWithResources/T7032633.java 2015-10-19 06:34:50.035907688 +0300 @@ -33,8 +33,15 @@ public class T7032633 { void test() throws IOException { + // declared resource try (OutputStream out = System.out) { out.flush(); } + + // resource as variable + OutputStream out = System.out; + try (out) { + out.flush(); + } } } --- old/test/tools/javac/TryWithResources/TwrForVariable1.java 2015-10-19 06:34:50.363907698 +0300 +++ new/test/tools/javac/TryWithResources/TwrForVariable1.java 2015-10-19 06:34:50.287907696 +0300 @@ -37,6 +37,33 @@ } assertCloseCount(6); + + // null test cases + TwrForVariable1 n = null; + + try (n) { + } + try (n) { + throw new Exception(); + } catch (Exception e) { + } + + assertCloseCount(6); + + // initialization exception + TwrForVariable1 i1 = new TwrForVariable1(); + try (i1; TwrForVariable1 i2 = new TwrForVariable1(true)) { + } catch (Exception e) { + } + + assertCloseCount(7); + + // multiple closures + TwrForVariable1 m1 = new TwrForVariable1(); + try (m1; TwrForVariable1 m2 = m1; TwrForVariable1 m3 = m2;) { + } + + assertCloseCount(10); } static void assertCloseCount(int expectedCloseCount) { @@ -66,4 +93,13 @@ closeCount++; } } + + public TwrForVariable1(boolean throwException) { + if (throwException) + throw new RuntimeException("Initialization exception"); + } + + public TwrForVariable1() { + this(false); + } } --- old/test/tools/javac/TryWithResources/TwrForVariable2.java 2015-10-19 06:34:50.623907706 +0300 +++ new/test/tools/javac/TryWithResources/TwrForVariable2.java 2015-10-19 06:34:50.539907703 +0300 @@ -7,7 +7,8 @@ public class TwrForVariable2 implements AutoCloseable { public static void main(String... args) { TwrForVariable2 v = new TwrForVariable2(); - TwrForVariable3[] v2 = new TwrForVariable3[1]; + TwrForVariable2[] v2 = new TwrForVariable2[1]; + TwrForVariable2[][] v3 = new TwrForVariable[1][1]; try (final v) { fail("no modifiers before variables"); @@ -24,9 +25,15 @@ try (v2[0]) { fail("array access not allowed"); } + try (v3[0][0]) { + fail("multidimentional array access not allowed"); + } try (args.length == 0 ? v : v) { fail("general expressions not allowed"); } + try ((TwrForVariable2)null) { + fail("null as variable is not allowed"); + } } static void fail(String reason) { --- old/test/tools/javac/TryWithResources/TwrForVariable2.out 2015-10-19 06:34:50.875907713 +0300 +++ new/test/tools/javac/TryWithResources/TwrForVariable2.out 2015-10-19 06:34:50.791907711 +0300 @@ -1,7 +1,9 @@ -TwrForVariable2.java:12:21: compiler.err.expected: token.identifier -TwrForVariable2.java:15:27: compiler.err.expected: token.identifier -TwrForVariable2.java:18:16: compiler.err.illegal.start.of.expr -TwrForVariable2.java:21:14: compiler.err.try.with.resources.expr.needs.var -TwrForVariable2.java:24:16: compiler.err.try.with.resources.expr.needs.var -TwrForVariable2.java:27:31: compiler.err.try.with.resources.expr.needs.var -6 errors +TwrForVariable2.java:13:21: compiler.err.expected: token.identifier +TwrForVariable2.java:16:27: compiler.err.expected: token.identifier +TwrForVariable2.java:19:16: compiler.err.illegal.start.of.expr +TwrForVariable2.java:22:14: compiler.err.try.with.resources.expr.needs.var +TwrForVariable2.java:25:16: compiler.err.try.with.resources.expr.needs.var +TwrForVariable2.java:28:19: compiler.err.try.with.resources.expr.needs.var +TwrForVariable2.java:31:31: compiler.err.try.with.resources.expr.needs.var +TwrForVariable2.java:34:14: compiler.err.try.with.resources.expr.needs.var +8 errors --- old/test/tools/javac/TryWithResources/TwrForVariable3.java 2015-10-19 06:34:51.131907721 +0300 +++ new/test/tools/javac/TryWithResources/TwrForVariable3.java 2015-10-19 06:34:51.059907719 +0300 @@ -7,9 +7,16 @@ public static void main(String... args) { TwrForVariable3 v1 = new TwrForVariable3(); Object v2 = new Object(); + Object v3 = new Object() { + public void close() { + } + }; try (v2) { - fail("no an AutoCloseable"); + fail("not an AutoCloseable"); + } + try (v3) { + fail("not an AutoCloseable although has close() method"); } try (java.lang.Object) { fail("not a variable access"); --- old/test/tools/javac/TryWithResources/TwrForVariable3.out 2015-10-19 06:34:51.367907728 +0300 +++ new/test/tools/javac/TryWithResources/TwrForVariable3.out 2015-10-19 06:34:51.295907726 +0300 @@ -1,4 +1,5 @@ -TwrForVariable3.java:11:14: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.AutoCloseable)) -TwrForVariable3.java:14:18: compiler.err.cant.resolve.location: kindname.class, lang, , , (compiler.misc.location: kindname.package, java, null) -TwrForVariable3.java:17:14: compiler.err.cant.resolve.location: kindname.variable, java, , , (compiler.misc.location: kindname.class, TwrForVariable3, null) -3 errors +TwrForVariable3.java:15:14: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.AutoCloseable)) +TwrForVariable3.java:18:14: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.AutoCloseable)) +TwrForVariable3.java:21:18: compiler.err.cant.resolve.location: kindname.class, lang, , , (compiler.misc.location: kindname.package, java, null) +TwrForVariable3.java:24:14: compiler.err.cant.resolve.location: kindname.variable, java, , , (compiler.misc.location: kindname.class, TwrForVariable3, null) +4 errors --- /dev/null 2015-08-31 00:12:54.703509796 +0300 +++ new/test/tools/javac/TryWithResources/ResourceVariableOutsideTry.java 2015-10-19 06:34:51.543907733 +0300 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015, 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 7196163 + * @summary Resource variable should be in scope throughout try, catch, and finally blocks + * @compile ResourceVariableOutsideTry.java + */ + +public class ResourceVariableOutsideTry { + void test() { + MyResource c = new MyResource(); + + try(c) { + c.test(); + } catch (Exception e) { + c.test(); + } finally { + c.test(); + } + } + + static class MyResource implements AutoCloseable { + public void close() throws Exception {} + void test() {} + } +} --- /dev/null 2015-08-31 00:12:54.703509796 +0300 +++ new/test/tools/javac/TryWithResources/TwrAndAnonymousClass.java 2015-10-19 06:34:51.771907740 +0300 @@ -0,0 +1,34 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7196163 + * @summary Twr with resource variables declared as anonymous class instance + * @compile/fail/ref=TwrAndAnonymousClass.out -XDrawDiagnostics TwrAndAnonymousClass.java + */ + +public class TwrAndAnonymousClass { + + public static void main(String... args) { + + // positive: anonymous class implementing AutoCloseable as variable in twr + AutoCloseable r1 = new AutoCloseable() { + public void close() { }; + }; + try (r1) { + } catch (Exception e) {} + + // positive: declaration of anonymous class implementing AutoCloseable in twr + try (AutoCloseable r2 = new AutoCloseable() { public void close() { }; };) { + } catch (Exception e) {} + + // negative: not AutoCloseable anonymous class as variable in twr + Object o1 = new Object() { + public void close() { }; + }; + try (o1) { + } catch (Exception e) {} + + // negative: declaration of not AutoCloseable anonymous class in twr + try (Object o2 = new Object() { public void close() { }; };) { + } catch (Exception e) {} + } +} --- /dev/null 2015-08-31 00:12:54.703509796 +0300 +++ new/test/tools/javac/TryWithResources/TwrAndAnonymousClass.out 2015-10-19 06:34:51.999907747 +0300 @@ -0,0 +1,3 @@ +TwrAndAnonymousClass.java:27:14: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.AutoCloseable)) +TwrAndAnonymousClass.java:31:21: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.AutoCloseable)) +2 errors --- /dev/null 2015-08-31 00:12:54.703509796 +0300 +++ new/test/tools/javac/TryWithResources/TwrAndLambda.java 2015-10-19 06:34:52.231907754 +0300 @@ -0,0 +1,55 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7196163 + * @summary Twr with resource variables as lambda expressions and method references + * @compile/fail/ref=TwrAndLambda.out -XDrawDiagnostics TwrAndLambda.java + */ + +public class TwrAndLambda { + + public static void main(String... args) { + + // Lambda expression + AutoCloseable v1 = () -> {}; + // Static method reference + AutoCloseable v2 = TwrAndLambda::close1; + // Instance method reference + AutoCloseable v3 = new TwrAndLambda()::close2; + // Lambda expression which is not AutoCloseable + Runnable r1 = () -> {}; + // Static method reference which is not AutoCloseable + Runnable r2 = TwrAndLambda::close1; + // Instance method reference which is not AutoCloseable + Runnable r3 = new TwrAndLambda()::close2; + + try (v1) { + } catch(Exception e) {} + try (v2) { + } catch(Exception e) {} + try (v3) { + } catch(Exception e) {} + try (r1) { + } catch(Exception e) {} + try (r2) { + } catch(Exception e) {} + try (r3) { + } catch(Exception e) {} + + // lambda invocation + I i = (x) -> { try(x) { } catch (Exception e) { } }; + i.m(v1); + i.m(v2); + i.m(v3); + i.m(r1); + i.m(r2); + i.m(r3); + } + + static interface I { + public void m(AutoCloseable r); + } + + public static void close1() { } + + public void close2() { } +} --- /dev/null 2015-08-31 00:12:54.703509796 +0300 +++ new/test/tools/javac/TryWithResources/TwrAndLambda.out 2015-10-19 06:34:52.443907760 +0300 @@ -0,0 +1,7 @@ +TwrAndLambda.java:31:14: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type: (compiler.misc.inconvertible.types: java.lang.Runnable, java.lang.AutoCloseable)) +TwrAndLambda.java:33:14: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type: (compiler.misc.inconvertible.types: java.lang.Runnable, java.lang.AutoCloseable)) +TwrAndLambda.java:35:14: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type: (compiler.misc.inconvertible.types: java.lang.Runnable, java.lang.AutoCloseable)) +TwrAndLambda.java:43:10: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.AutoCloseable, java.lang.Runnable, kindname.interface, TwrAndLambda.I, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.Runnable, java.lang.AutoCloseable)) +TwrAndLambda.java:44:10: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.AutoCloseable, java.lang.Runnable, kindname.interface, TwrAndLambda.I, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.Runnable, java.lang.AutoCloseable)) +TwrAndLambda.java:45:10: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.AutoCloseable, java.lang.Runnable, kindname.interface, TwrAndLambda.I, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.Runnable, java.lang.AutoCloseable)) +6 errors --- /dev/null 2015-08-31 00:12:54.703509796 +0300 +++ new/test/tools/javac/TryWithResources/TwrAndTypeVariables.java 2015-10-19 06:34:52.683907767 +0300 @@ -0,0 +1,23 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7196163 + * @summary Twr with resource variables of parametrized types + * @compile/fail/ref=TwrAndTypeVariables.out -XDrawDiagnostics TwrAndTypeVariables.java + */ + +public class TwrAndTypeVariables { + + // positive + public static + void copy(S s, T t) throws Exception { + try (s; t;) { + } + } + + // negative + public static void copy(S s) throws Exception { + try (s) { + } + } +} --- /dev/null 2015-08-31 00:12:54.703509796 +0300 +++ new/test/tools/javac/TryWithResources/TwrAndTypeVariables.out 2015-10-19 06:34:52.915907774 +0300 @@ -0,0 +1,2 @@ +TwrAndTypeVariables.java:20:14: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type: (compiler.misc.inconvertible.types: S, java.lang.AutoCloseable)) +1 error --- /dev/null 2015-08-31 00:12:54.703509796 +0300 +++ new/test/tools/javac/TryWithResources/TwrVarAndDecl.java 2015-10-19 06:34:53.159907781 +0300 @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015, 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 7196163 + * @summary Variable and direct declaration both in one twr block + */ + +public class TwrVarAndDecl implements AutoCloseable { + + public static void main(String... args) { + TwrVarAndDecl r = new TwrVarAndDecl(); + + try (r; TwrVarAndDecl r2 = new TwrVarAndDecl();) { + } + } + + public void close() {} +} --- /dev/null 2015-08-31 00:12:54.703509796 +0300 +++ new/test/tools/javac/TryWithResources/TwrVarKinds.java 2015-10-19 06:34:53.407907788 +0300 @@ -0,0 +1,81 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7196163 + * @summary Twr with different kinds of variables: local, instance, class, parameter + * @compile/fail/ref=TwrVarKinds.out -XDrawDiagnostics TwrVarKinds.java + */ + +public class TwrVarKinds implements AutoCloseable { + + final static TwrVarKinds r1 = new TwrVarKinds(); + final TwrVarKinds r2 = new TwrVarKinds(); + static TwrVarKinds r3 = new TwrVarKinds(); + TwrVarKinds r4 = new TwrVarKinds(); + + public static void main(String... args) { + + TwrVarKinds r5 = new TwrVarKinds(); + + /* static final field - ok */ + try (r1) { + } + + /* non-static final field - ok */ + try (r1.r2) { + } + + /* static non-final field - wrong */ + try (r3) { + } + + /* non-static non-final field - wrong */ + try (r1.r4) { + } + + /* local variable - ok */ + try (r5) { + } + + /* method parameter - ok */ + method(r5); + + /* constructor parameter - ok */ + TwrVarKinds r6 = new TwrVarKinds(r5); + + /* lambda parameter - ok */ + I i = (x) -> { try (x) {} }; + i.m(r5); + + /* exception parameter - ok */ + try { + throw new ResourceException(); + } catch (ResourceException e) { + try (e) { + } + } + } + + public TwrVarKinds() { + } + + public TwrVarKinds(TwrVarKinds r) { + try (r) { + } + } + + static void method(TwrVarKinds r) { + /* parameter */ + try (r) { + } + } + + public void close() {} + + static interface I { + public void m(TwrVarKinds r); + } + + static class ResourceException extends Exception implements AutoCloseable { + public void close() {} + } +} --- /dev/null 2015-08-31 00:12:54.703509796 +0300 +++ new/test/tools/javac/TryWithResources/TwrVarKinds.out 2015-10-19 06:34:53.647907796 +0300 @@ -0,0 +1,3 @@ +TwrVarKinds.java:28:14: compiler.err.try.with.resources.expr.effectively.final.var: r3 +TwrVarKinds.java:32:16: compiler.err.try.with.resources.expr.effectively.final.var: r4 +2 errors --- /dev/null 2015-08-31 00:12:54.703509796 +0300 +++ new/test/tools/javac/TryWithResources/TwrVarRedeclaration.java 2015-10-19 06:34:53.879907802 +0300 @@ -0,0 +1,28 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7196163 + * @summary Variable redeclaration inside twr block + * @compile/fail/ref=TwrVarRedeclaration.out -XDrawDiagnostics TwrVarRedeclaration.java + */ + +public class TwrVarRedeclaration implements AutoCloseable { + + public static void main(String... args) { + TwrVarRedeclaration r = new TwrVarRedeclaration(); + + try (r) { + TwrVarRedeclaration r = new TwrVarRedeclaration(); + } + + try (r) { + Object r = new Object(); + } + + try (r) { + } catch (Exception e) { + Exception r = new Exception(); + } + } + + public void close() {} +} --- /dev/null 2015-08-31 00:12:54.703509796 +0300 +++ new/test/tools/javac/TryWithResources/TwrVarRedeclaration.out 2015-10-19 06:34:54.115907809 +0300 @@ -0,0 +1,4 @@ +TwrVarRedeclaration.java:14:33: compiler.err.already.defined: kindname.variable, r, kindname.method, main(java.lang.String...) +TwrVarRedeclaration.java:18:20: compiler.err.already.defined: kindname.variable, r, kindname.method, main(java.lang.String...) +TwrVarRedeclaration.java:23:23: compiler.err.already.defined: kindname.variable, r, kindname.method, main(java.lang.String...) +3 errors --- /dev/null 2015-08-31 00:12:54.703509796 +0300 +++ new/test/tools/javac/TryWithResources/WeirdTwr_WithVar.java 2015-10-19 06:34:54.363907817 +0300 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2015, 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 7196163 6911256 6964740 + * @summary Strange TWRs with resource variables + */ + +public class WeirdTwr_WithVar implements AutoCloseable { + private static int closeCount = 0; + + public static void main(String... args) { + WeirdTwr_WithVar r1 = new WeirdTwr_WithVar(); + + try (r1; WeirdTwr_WithVar r2 = r1;) { + if (r1 != r2) + throw new RuntimeException("Unexpected inequality."); + } + + if (closeCount != 2) + throw new RuntimeException("Bad closeCount " + closeCount); + } + + public void close() { + closeCount++; + } +} --- /dev/null 2015-08-31 00:12:54.703509796 +0300 +++ new/test/tools/javac/defaultMethods/private/PrivateGenerics.java 2015-10-19 06:34:54.603907824 +0300 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2015, 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 8071453 + * @summary Verify that generics work with private method in interface + */ + +public class PrivateGenerics { + + interface I { + private T foo() { return null; }; + default void m(T t) { + T t1 = t; + T t2 = foo(); + } + } + + interface J { + private M foo() { return null; } + default void m(N n) { + N n1 = n; + N n2 = foo(); + } + } + + public static void main(String[] args) { + I i = new I<>() {}; + i.m("string"); + String s = i.foo(); + + J j = new J() {}; + j.m("string"); + s = j.foo(); + } +}