Bug 42692 - JavaCC files cause VerifyError when compiled with Eclipse
Summary: JavaCC files cause VerifyError when compiled with Eclipse
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Linux
: P3 blocker (vote)
Target Milestone: 3.0 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-09-08 07:47 EDT by Gerard Milmeister CLA
Modified: 2003-10-18 08:00 EDT (History)
3 users (show)

See Also:


Attachments
Compile this file using latest head contents (1.88 KB, text/plain)
2003-09-23 16:03 EDT, Olivier Thomann CLA
no flags Details
Simpler test case (671 bytes, text/plain)
2003-09-23 16:14 EDT, Olivier Thomann CLA
no flags Details
JavaCC generated file (20.16 KB, text/plain)
2003-09-23 16:45 EDT, Dorian Birsan CLA
no flags Details
Simplest test case ever (352 bytes, text/plain)
2003-09-23 16:57 EDT, Fernando Colombo CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gerard Milmeister CLA 2003-09-08 07:47:48 EDT
I have a .jj file that is processed using JavaCC.
If these files are compiled using command line javac
(with debug on or off) or within Eclipse using Ant,
the program runs correctly. However, when compiled
using Eclipse, I get an error like the following:

Exception in thread "main" java.lang.VerifyError: (class:
org/rubato/rubettes/denotex/DenotexParser, method: basicModule signature:
()Lorg/rubato/math/module/Module;) Illegal target of jump or branch

Here DenotexParser is the file generated by JavaCC, basicModule
is a method generated from a rule in the JavaCC file, that returns
an object of class Module.
Comment 1 Philipe Mulet CLA 2003-09-08 09:05:47 EDT
Which Eclipse build are you using ? Also, can you attach the entire testcase 
with steps ? A verify error sounds bad.

Please reopen defect once requested information is available.
Comment 2 Gerard Milmeister CLA 2003-09-23 09:52:54 EDT
Currently I am running Build id: 200309170800.
What do you mean by a testcase. What files/output
do you expect that I supply?
Comment 3 Olivier Thomann CLA 2003-09-23 15:34:06 EDT
We would like to get the source of this class:
org.rubato.rubettes.denotex.DenotexParser

Ideally it would be great if you could provide enough classes to be able to
compile without errors.
Comment 4 Olivier Thomann CLA 2003-09-23 16:02:14 EDT
I isolated a test case from the same error in the Help component.
See attach file. I will investigate to reduce it to a simple test case.
Comment 5 Olivier Thomann CLA 2003-09-23 16:03:36 EDT
Created attachment 6198 [details]
Compile this file using latest head contents

We might want to fix this bug before switching compiler for the build.
Comment 6 Olivier Thomann CLA 2003-09-23 16:14:38 EDT
Created attachment 6199 [details]
Simpler test case
Comment 7 Olivier Thomann CLA 2003-09-23 16:19:20 EDT
Increase severity since we have a test case to reproduce the problem and it
seems that the Help component hits the same issue.
Here are our bytecodes for the simpler test case:

  final public void foo();
    /* Stack: 1, Locals: 4 */
    Code attribute:
       0  iconst_0
       1  istore_1
       2  iconst_0
       3  istore_2
       4  iconst_0
       5  istore_3
       6  iload_1
       7  tableswitch default: 25
            case 0: 24
      24  return
      25  iload_3
      26  ifeq 33
      29  return
      30  goto 82 <================= THIS IS ILLEGAL
      33  iload_1
      34  tableswitch default: 53
            case 0: 52
      52  return
      53  iload_2
      54  ifeq 61
      57  return
      58  goto 82  <================= THIS IS ILLEGAL
      61  iload_1
      62  tableswitch default: 81
            case 0: 80
      80  return
      81  return
Comment 8 Olivier Thomann CLA 2003-09-23 16:20:45 EDT
Compiled with javac 1.4.1, we get:
  /*  Method descriptor  #5 ()V */
  final public void foo();
    /* Stack: 1, Locals: 4 */
    Code attribute:
       0  iconst_0
       1  istore_1
       2  iconst_0
       3  istore_2
       4  iconst_0
       5  istore_3
       6  iload_1
       7  lookupswitch default: 25
            case 0: 24
      24  return
      25  iload_3
      26  ifeq 30
      29  return
      30  iload_1
      31  lookupswitch default: 49
            case 0: 48
      48  return
      49  iload_2
      50  ifeq 54
      53  return
      54  iload_1
      55  lookupswitch default: 73
            case 0: 72
      72  return
      73  return
Comment 9 Olivier Thomann CLA 2003-09-23 16:22:20 EDT
If we look at our bytecode, the two illegal goto are unreachable.
Comment 10 Dorian Birsan CLA 2003-09-23 16:43:00 EDT
We have a similar issue in help, with one of the JavaCC generated files.
I will attach the file with problems, but if you want to run something to 
reproduce the problem:
- extract org.apache.lucene from HEAD 
- run as "Run-time Workbench"
- in the eclipse instance that comes up launch help Help->Help Contents.
- after help browser is showing the eclipse books, enter some text in the 
search entry field and hit go.
- you'll see the error in the console:

java.lang.VerifyError: (class: org/apache/lucene/demo/html/HTMLParser, method: 
ArgValue signature: ()Lorg/apache/lucene/demo/html/Token;) Illegal target of 
jump or branch
	at org.eclipse.help.internal.search.HTMLDocParser.openDocument
(HTMLDocParser.java:74)
	at org.eclipse.help.internal.search.SearchIndex.addDocument
(SearchIndex.java:112)
	at org.eclipse.help.internal.search.IndexingOperation.addDocuments
(IndexingOperation.java:107)
	at org.eclipse.help.internal.search.IndexingOperation.execute
(IndexingOperation.java:88)
	at org.eclipse.help.internal.search.SearchManager.updateIndex
(SearchManager.java:148)
	at org.eclipse.help.internal.search.SearchManager.search
(SearchManager.java:89)
	at org.eclipse.help.internal.search.SearchProgressMonitor$2.run
(SearchProgressMonitor.java:144)
	at java.lang.Thread.run(Thread.java:536)
Comment 11 Dorian Birsan CLA 2003-09-23 16:45:03 EDT
Created attachment 6204 [details]
JavaCC generated file
Comment 12 Fernando Colombo CLA 2003-09-23 16:57:34 EDT
Created attachment 6205 [details]
Simplest test case ever
Comment 13 Olivier Thomann CLA 2003-09-23 16:59:09 EDT
Dorian,

The simpler test case is extracted from your example.

The goto is generated inside the if statement when there is a else statement and
the then statement is not considered as returning.
I think this is where the bug is coming from. Debugging the simpler test case,
it appears that the if statements that generates the illegal gotos are the ones
with a condition.
if (b1) {
	if (true)
		return;
} else {
	switch (i) {
		case 0 :
			if (true)
				return;
			break;
		default :
			if (b) {
				if (true)
					return;
			} else {
				switch (i) {
					case 0 :
						if (true)
							return;
						break;
					default :
						return;
				}
			}
	}
}

The then clause of this if
if (b1) {
	if (true)
		return;
} else {

is considered as not exiting, but it does. At least the code generation
considers that it does. So we need to be consistent. The thenFlowInfo is
considered as unreachable. Is this equivalent to a DEAD_END?
Comment 14 Philipe Mulet CLA 2003-09-23 17:06:23 EDT
Will investigate a fix. It is actually a consequence of another fix for bug 
40736.
Comment 15 Philipe Mulet CLA 2003-09-23 17:33:01 EDT
Bug 40736 was an incorrect diagnosis during flow analysis due to fake reachable 
code in an IF statement. In order to fix it, I had changed the value of the 
flag #thenExit to be (flowInfo == DEAD_END) instead of !flowInfo.isReachable().
This behavior gave the proper flow analysis behavior, but broke code gen which 
did expect the flag to be position whenever the flow info isn't reachable (i.e. 
truly unreachable or fake reachable).

Change is being tested.
Comment 16 Philipe Mulet CLA 2003-09-23 17:40:14 EDT
Fix integrated. Will soon post a patch of JDTCore in our download area:

http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/jdt-core-
home/r3.0/main.html#updates

Regression tests added.
Comment 17 Philipe Mulet CLA 2003-09-24 03:41:16 EDT
Confirming patch went out. Will release for integration rebuild.
Comment 18 David Audel CLA 2003-10-14 11:14:05 EDT
Verified.
Comment 19 Philipe Mulet CLA 2003-10-18 08:00:26 EDT
Regression test is InitializationTest#test166