Similar to CR 6608214, but the test code is different. An exception is thrown while executing the test case given below:
java.lang.ClassCastException: com.sun.tools.javac.code.Symbol$TypeSymbol cannot be cast to com.sun.tools.javac.code.Symbol$ClassSymbol
at com.sun.tools.javac.comp.Check.checkImplementations(Check.java:1558)
at com.sun.tools.javac.comp.Check.checkImplementations(Check.java:1549)
at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2730)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2660)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2596)
at com.sun.tools.javac.comp.Attr.attribBounds(Attr.java:480)
at com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:584)
at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:653)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:372)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:409)
at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2734)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2660)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2596)
at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1055)
at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1031)
at com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:369)
at com.sun.tools.javac.api.JavacTaskImpl.analyze(JavacTaskImpl.java:349)
at T9999999.main(T9999999.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:623)
at com.sun.javatest.regtest.MainAction$SameVMThread.run(MainAction.java:560)
at java.lang.Thread.run(Thread.java:675)
/*
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 9999999
* @summary Exception throw while analysing a file with error
* @author Maurizio Cimadamore
*/
import com.sun.source.util.JavacTask;
import java.io.IOException;
import java.net.URI;
import java.util.Arrays;
import java.util.List;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import javax.tools.ToolProvider;
import static javax.tools.JavaFileObject.Kind;
public class T9999999 {
public static void main(String[] args) throws IOException {
JavaFileObject sfo = new SimpleJavaFileObject(URI.create(""),Kind.SOURCE) {
public CharSequence getCharContent(boolean ignoreEncodingErrors) {
return "package test; public class Test { <D, T extends Runnable & D> void f() {} }";
}
};
List<? extends JavaFileObject> files = Arrays.asList(sfo);
String bootPath = System.getProperty("sun.boot.class.path");
List<String> opts = Arrays.asList("-bootclasspath", bootPath, "-Xjcov");
JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
JavacTask ct = (JavacTask)tool.getTask(null, null, null,opts,null,files);
ct.analyze();
}
}
Tested on langtools from:
http://hg.openjdk.java.net/jdk7/tl/langtools
tip: 058bdd3ca02e
See also NetBeans bug:
http://www.netbeans.org/issues/show_bug.cgi?id=131101