JDK-6999635 : Multicatch: crash while compiling simple code with a multicatch parameter
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: unknown
  • Submitted: 2010-11-12
  • Updated: 2022-07-08
  • Resolved: 2011-05-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b120Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
The following code crashes javac:

class Crash {
	     
		interface Foo {}
		static class X1 extends Exception implements Foo {}
		static class X2 extends Exception implements Foo {}

		public static void main(String[] args) {
			try {
				if (args.length == 0)
					throw new X1();
				else
					throw new X2();
			}
			catch (X1|X2 ex) {
			}
		}
	}

Stack:

An exception has occurred in the compiler (1.7.0-internal). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report.  Thank you.
	java.lang.AssertionError
	        at com.sun.tools.javac.jvm.ClassWriter.enterInner(ClassWriter.java:996)
	        at com.sun.tools.javac.jvm.ClassWriter.writePool(ClassWriter.java:533)
	        at com.sun.tools.javac.jvm.ClassWriter.writeClassFile(ClassWriter.java:1698)
	        at com.sun.tools.javac.jvm.ClassWriter.writeClass(ClassWriter.java:1579)
	        at com.sun.tools.javac.main.JavaCompiler.genCode(JavaCompiler.java:685)
	        at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1413)
	        at com.sun.tools.javac.main.JavaCompiler.generate(JavaCompiler.java:1381)
	        at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:836)
	        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:795)
	        at com.sun.tools.javac.main.Main.compile(Main.java:418)
	        at com.sun.tools.javac.main.Main.compile(Main.java:336)
	        at com.sun.tools.javac.main.Main.compile(Main.java:327)
	        at com.sun.tools.javac.Main.compile(Main.java:82)
	        at com.sun.tools.javac.Main.main(Main.java:67)

Comments
EVALUATION http://hg.openjdk.java.net/jdk7/build/langtools/rev/1dd813a529cf
04-12-2010

SUGGESTED FIX A webrev of this fix is available at the following URL: http://hg.openjdk.java.net/jdk7/tl/langtools/rev/1dd813a529cf
15-11-2010

EVALUATION The problem is caused by the fact that the compiler uses a lub approximation of the disjunctive type X1 | X2 = lub(X1,X2) = Exception & Foo. It seems like, when stack maps of method main is generated, the type of the local variale 'ex' is not erased, causing javac to emit a constant pool entry whose type is an intersection type, which is forbidden. Note that this particular situation can never arise in a non-multi-catch case, as the type of a variable cannot be an intersection type (users are not allowed to declare variables whose type is a non-denotable type).
12-11-2010