Tue, 04 Mar 2008 15:19:06 +0000
6608214: Exception throw while analysing a file with error
Summary: bad error-recovery after bad type-variable bound is detected
Reviewed-by: jjg
src/share/classes/com/sun/tools/javac/comp/Attr.java | file | annotate | diff | comparison | revisions | |
test/tools/javac/api/6608214/T6608214.java | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Mar 04 13:00:08 2008 +0000 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Mar 04 15:19:06 2008 +0000 1.3 @@ -2514,6 +2514,7 @@ 1.4 log.error(tree.bounds.tail.head.pos(), 1.5 "type.var.may.not.be.followed.by.other.bounds"); 1.6 tree.bounds = List.of(tree.bounds.head); 1.7 + a.bound = bs.head; 1.8 } 1.9 } else { 1.10 // if first bound was a class or interface, accept only interfaces
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/tools/javac/api/6608214/T6608214.java Tue Mar 04 15:19:06 2008 +0000 2.3 @@ -0,0 +1,56 @@ 2.4 +/* 2.5 + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. 2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 + * 2.8 + * This code is free software; you can redistribute it and/or modify it 2.9 + * under the terms of the GNU General Public License version 2 only, as 2.10 + * published by the Free Software Foundation. 2.11 + * 2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.15 + * version 2 for more details (a copy is included in the LICENSE file that 2.16 + * accompanied this code). 2.17 + * 2.18 + * You should have received a copy of the GNU General Public License version 2.19 + * 2 along with this work; if not, write to the Free Software Foundation, 2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.21 + * 2.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 2.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 2.24 + * have any questions. 2.25 + */ 2.26 + 2.27 +/* 2.28 + * @test 2.29 + * @bug 6608214 2.30 + * @summary Exception throw while analysing a file with error 2.31 + * @author Maurizio Cimadamore 2.32 + */ 2.33 + 2.34 +import com.sun.source.util.JavacTask; 2.35 +import java.io.IOException; 2.36 +import java.net.URI; 2.37 +import java.util.Arrays; 2.38 +import java.util.List; 2.39 +import javax.tools.JavaCompiler; 2.40 +import javax.tools.JavaFileObject; 2.41 +import javax.tools.SimpleJavaFileObject; 2.42 +import javax.tools.ToolProvider; 2.43 +import static javax.tools.JavaFileObject.Kind; 2.44 + 2.45 +public class T6608214 { 2.46 + public static void main(String[] args) throws IOException { 2.47 + JavaFileObject sfo = new SimpleJavaFileObject(URI.create(""),Kind.SOURCE) { 2.48 + public CharSequence getCharContent(boolean ignoreEncodingErrors) { 2.49 + return "class Test<S> { <T extends S & Runnable> void test(){}}"; 2.50 + } 2.51 + }; 2.52 + List<? extends JavaFileObject> files = Arrays.asList(sfo); 2.53 + String bootPath = System.getProperty("sun.boot.class.path"); 2.54 + List<String> opts = Arrays.asList("-bootclasspath", bootPath, "-Xjcov"); 2.55 + JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); 2.56 + JavacTask ct = (JavacTask)tool.getTask(null, null, null,opts,null,files); 2.57 + ct.analyze(); 2.58 + } 2.59 +}