1.1 --- a/test/tools/javac/T8029240/DefaultMethodsNotVisibileForSource7Test.java Thu Feb 06 21:03:03 2014 +0000 1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 @@ -1,164 +0,0 @@ 1.4 -/* 1.5 - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 1.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 - * 1.8 - * This code is free software; you can redistribute it and/or modify it 1.9 - * under the terms of the GNU General Public License version 2 only, as 1.10 - * published by the Free Software Foundation. 1.11 - * 1.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 - * version 2 for more details (a copy is included in the LICENSE file that 1.16 - * accompanied this code). 1.17 - * 1.18 - * You should have received a copy of the GNU General Public License version 1.19 - * 2 along with this work; if not, write to the Free Software Foundation, 1.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 - * 1.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 - * or visit www.oracle.com if you need additional information or have any 1.24 - * questions. 1.25 - */ 1.26 - 1.27 -/* 1.28 - * @test 1.29 - * @bug 8029240 1.30 - * @summary Default methods not always visible under -source 7 1.31 - * @library /tools/javac/lib 1.32 - * @build ToolBox 1.33 - * @run main DefaultMethodsNotVisibileForSource7Test 1.34 - */ 1.35 - 1.36 -import java.nio.file.Files; 1.37 -import java.nio.file.Paths; 1.38 - 1.39 -public class DefaultMethodsNotVisibileForSource7Test { 1.40 - // common definitions 1.41 - 1.42 - // this one should be compiled with source 8, the rest with source 7 1.43 - static final String ISrc = 1.44 - "interface I {\n" + 1.45 - " default void m() {}\n" + 1.46 - "}"; 1.47 - 1.48 - static final String JSrc = 1.49 - "interface J extends I {}"; 1.50 - 1.51 - static final String ASrc = 1.52 - "abstract class A implements I {}"; 1.53 - 1.54 - static final String BSrc = 1.55 - "class B implements I {}"; 1.56 - 1.57 - // test legacy implementations 1.58 - static final String C1Src = 1.59 - "class C1 implements I {\n" + 1.60 - " @Override public void m() {}\n" + 1.61 - "}"; 1.62 - 1.63 - static final String C2Src = 1.64 - "class C2 implements J {\n" + 1.65 - " @Override public void m() {}\n" + 1.66 - "}"; 1.67 - 1.68 - static final String C3Src = 1.69 - "class C3 extends A {\n" + 1.70 - " @Override public void m() {}\n" + 1.71 - "}"; 1.72 - 1.73 - static final String C4Src = 1.74 - "class C4 extends B {\n" + 1.75 - " @Override public void m() {}\n" + 1.76 - "}"; 1.77 - 1.78 - //test legacy invocations 1.79 - static final String LegacyInvocationSrc = 1.80 - "class LegacyInvocation {\n" + 1.81 - " public static void test(I i, J j, A a, B b) {\n" + 1.82 - " i.m();\n" + 1.83 - " j.m();\n" + 1.84 - " a.m();\n" + 1.85 - " b.m();\n" + 1.86 - " }\n" + 1.87 - "}"; 1.88 - 1.89 - //test case super invocations 1.90 - static final String SubASrc = 1.91 - "class SubA extends A {\n" + 1.92 - " public void test() {\n" + 1.93 - " super.m();\n" + 1.94 - " }\n" + 1.95 - "}"; 1.96 - 1.97 - static final String SubBSrc = 1.98 - "class SubB extends B {\n" + 1.99 - " public void test() {\n" + 1.100 - " super.m();\n" + 1.101 - " }\n" + 1.102 - "}"; 1.103 - 1.104 - public static void main(String[] args) throws Exception { 1.105 - new DefaultMethodsNotVisibileForSource7Test().run(); 1.106 - } 1.107 - 1.108 - void run() throws Exception { 1.109 - testsPreparation(); 1.110 - testLegacyImplementations(); 1.111 - testLegacyInvocations(); 1.112 - testSuperInvocations(); 1.113 - } 1.114 - 1.115 - void testsPreparation() throws Exception { 1.116 - Files.createDirectory(Paths.get("out")); 1.117 - 1.118 - /* as an extra check let's make sure that interface 'I' can't be compiled 1.119 - * with source 7 1.120 - */ 1.121 - ToolBox.JavaToolArgs javacArgs = 1.122 - new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL) 1.123 - .setOptions("-d", "out", "-source", "7") 1.124 - .setSources(ISrc); 1.125 - ToolBox.javac(javacArgs); 1.126 - 1.127 - //but it should compile with source >= 8 1.128 - javacArgs = 1.129 - new ToolBox.JavaToolArgs() 1.130 - .setOptions("-d", "out") 1.131 - .setSources(ISrc); 1.132 - ToolBox.javac(javacArgs); 1.133 - 1.134 - javacArgs = 1.135 - new ToolBox.JavaToolArgs() 1.136 - .setOptions("-cp", "out", "-d", "out", "-source", "7") 1.137 - .setSources(JSrc, ASrc, BSrc); 1.138 - ToolBox.javac(javacArgs); 1.139 - } 1.140 - 1.141 - void testLegacyImplementations() throws Exception { 1.142 - //compile C1-4 1.143 - ToolBox.JavaToolArgs javacArgs = 1.144 - new ToolBox.JavaToolArgs() 1.145 - .setOptions("-cp", "out", "-d", "out", "-source", "7") 1.146 - .setSources(C1Src, C2Src, C3Src, C4Src); 1.147 - ToolBox.javac(javacArgs); 1.148 - } 1.149 - 1.150 - void testLegacyInvocations() throws Exception { 1.151 - //compile LegacyInvocation 1.152 - ToolBox.JavaToolArgs javacArgs = 1.153 - new ToolBox.JavaToolArgs() 1.154 - .setOptions("-cp", "out", "-d", "out", "-source", "7") 1.155 - .setSources(LegacyInvocationSrc); 1.156 - ToolBox.javac(javacArgs); 1.157 - } 1.158 - 1.159 - void testSuperInvocations() throws Exception { 1.160 - //compile SubA, SubB 1.161 - ToolBox.JavaToolArgs javacArgs = 1.162 - new ToolBox.JavaToolArgs() 1.163 - .setOptions("-cp", "out", "-d", "out", "-source", "7") 1.164 - .setSources(SubASrc, SubBSrc); 1.165 - ToolBox.javac(javacArgs); 1.166 - } 1.167 -}