United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 6481701 annot00701.html, annot01602m3.html and intf01004m1.html hang while compiling (b102)
6481701 : annot00701.html, annot01602m3.html and intf01004m1.html hang while compiling (b102)

Details
Type:
Bug
Submit Date:
2006-10-13
Status:
Closed
Updated Date:
2012-03-22
Project Name:
JDK
Resolved Date:
2011-03-07
Component:
tools
OS:
generic,windows_xp
Sub-Component:
javac
CPU:
x86,generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6,6u1
Fixed Versions:
7

Related Reports
Backport:
Duplicate:
Duplicate:
Relates:
Relates:

Sub Tasks

Description
JCK            : JCK6.0 b32, JCK1.5a b11
J2SE           : FAIL - mustang b102, since b91 PASS b90
Platform[s]    : FAIL - seems to be all
switch/Mode    : FAIL - fail with defaut keys

Three tests:

lang/ANNOT/annot007/annot00701/annot00701.html
lang/ANNOT/annot016/annot01602m3/annot01602m3.html
lang/INTF/intf010/intf01004m1/intf01004m1.html

Are wrongly determined as "passed" by JDK 1.6. Tests expect java classses to be rejected due to wrong syntax. Unfortunately real situation is that compiler shows error and then starts to collect system resources then throw error:

The system is out of resources.
Consult the following stack trace for details.
java.lang.OutOfMemoryError: Java heap space
	at java.lang.String.toLowerCase(String.java:2418)
	at java.io.Win32FileSystem.hashCode(Win32FileSystem.java:581)
	at java.io.File.hashCode(File.java:1893)
	at com.sun.tools.javac.util.DefaultFileManager$RegularFileObject.hashCode(DefaultFileManager.java:1272)
	at com.sun.tools.javac.util.Pair.hashCode(Pair.java:49)
	at java.util.HashMap.getEntry(HashMap.java:344)
	at java.util.HashMap.containsKey(HashMap.java:335)
	at java.util.HashSet.contains(HashSet.java:184)
	at com.sun.tools.javac.util.Log.shouldReport(Log.java:276)
	at com.sun.tools.javac.util.Log.report(Log.java:535)
	at com.sun.tools.javac.util.Log.error(Log.java:412)
	at com.sun.tools.javac.parser.Parser.reportSyntaxError(Parser.java:280)
	at com.sun.tools.javac.parser.Parser.syntaxError(Parser.java:267)
	at com.sun.tools.javac.parser.Parser.syntaxError(Parser.java:262)
	at com.sun.tools.javac.parser.Parser.illegal(Parser.java:319)
	at com.sun.tools.javac.parser.Parser.illegal(Parser.java:326)
	at com.sun.tools.javac.parser.Parser.term3(Parser.java:1053)
	at com.sun.tools.javac.parser.Parser.term2(Parser.java:681)
	at com.sun.tools.javac.parser.Parser.term1(Parser.java:652)
	at com.sun.tools.javac.parser.Parser.term(Parser.java:608)
	at com.sun.tools.javac.parser.Parser.term(Parser.java:590)
	at com.sun.tools.javac.parser.Parser.type(Parser.java:584)
	at com.sun.tools.javac.parser.Parser.classOrInterfaceBodyDeclaration(Parser.java:2464)
	at com.sun.tools.javac.parser.Parser.classOrInterfaceBody(Parser.java:2403)
	at com.sun.tools.javac.parser.Parser.interfaceDeclaration(Parser.java:2272)
	at com.sun.tools.javac.parser.Parser.classOrInterfaceOrEnumDeclaration(Parser.java:2188)
	at com.sun.tools.javac.parser.Parser.typeDeclaration(Parser.java:2175)
	at com.sun.tools.javac.parser.Parser.compilationUnit(Parser.java:2121)
	at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:509)
	at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:550)
	at com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:801)
	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)

We found this error while performing test with JCK 1.5a b11 and JDK 6.0 compiler with "-target 1.5". Tests were rejected as hung.

jdk 1.5 u9 compiler rejects these tests correctly.

jtr's attached.

                                    

Comments
EVALUATION

No new tests have been developed for this fix since this is tested by
JCK.  I have verified that the affected tests complete without crash.
                                     
2006-10-20
SUGGESTED FIX

Index: j2se/src/share/classes/com/sun/tools/javac/parser/Parser.java
--- /tmp/geta12781	2006-10-19 17:25:30.000000000 -0700
+++ Parser.java	2006-10-19 15:43:04.000000000 -0700
@@ -268,6 +268,7 @@
 	return toP(F.at(pos).Erroneous(errs));
     }
 
+    private int errorPos = Position.NOPOS;
     /**
      * Report a syntax error at given position using the given
      * argument unless one was already reported at the same position.
@@ -280,6 +281,9 @@
 		log.error(pos, key, arg);
 	}
 	S.errPos(pos);
+        if (S.pos() == errorPos)
+            S.nextToken(); // guarantee progress
+        errorPos = S.pos();
     }
                                     
2006-10-20
SUGGESTED FIX

Webrev of changes: http://sa.sfbay/projects/langtools/bugid_summary.pl?bugid=6481701
See also attachment 6481701.tar.gz.
                                     
2006-10-20
EVALUATION

The compiler should not crash or hang.
                                     
2006-10-19



Hardware and Software, Engineered to Work Together