Bug 18724 - Code for the static initializer is exceeding the 65535 bytes limit
Summary: Code for the static initializer is exceeding the 65535 bytes limit
Status: VERIFIED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 F3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-06-03 10:32 EDT by Sabri Buyuksoy CLA
Modified: 2002-06-04 11:25 EDT (History)
0 users

See Also:


Attachments
test case (176.91 KB, text/plain)
2002-06-04 10:18 EDT, Olivier Thomann CLA
no flags Details
Defining class with a try/catch statement (177.00 KB, text/plain)
2002-06-04 11:25 EDT, Olivier Thomann CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sabri Buyuksoy CLA 2002-06-03 10:32:44 EDT
I got "Code for the static initializer is exceeding the 65535 bytes limit"
compile error from an interface containing a String[] of 8297 elements.
I don't get the same error when I compile with javac. The interface looks
like following:

public interface I
{
 String s[] =
 {
  "a",
  "b",
  .
  .
  .
 };
}
Comment 1 Olivier Thomann CLA 2002-06-03 10:37:38 EDT
Please provide the whole source in attachment. We need it to reproduce the problem and compare 
generated code between javac and our compiler.
Comment 2 Philipe Mulet CLA 2002-06-03 11:15:18 EDT
This could indeed be a scenario where you are getting close to the threshold 
were we throw the towel and refuse to compile the method as it would be to big.

It might be a good idea to consider using a separate file to load this table 
from, given it will cost you twice in memory: once for the big classfile loaded 
in memory, and once more for the runtime table data structure.

Now this being said, it is still a valid test case for us to check our behavior 
against other compilers.
Comment 3 Olivier Thomann CLA 2002-06-04 10:18:58 EDT
Created attachment 1220 [details]
test case
Comment 4 Olivier Thomann CLA 2002-06-04 10:21:48 EDT
JDK1.3.1 and 1.4 don't complain anymore about methods bigger than 65535 bytes. However JDK1.2.2 
reports the following warning:
D:\temp>javac 
CoreBagKeyNames.java
CoreBagKeyNames.java:10135: This code requires generating a method 
with more than 64K bytes.  Virtual machines may refuse the resulting class file.
                
"VADESUREAY",
                ^
1 warning
We might want to issue a warning as well and allowed the .class 
file to be generated.

I checked that the JDK1.4 procuded a method with 65565 bytes. Here is the 
end of the disassembled .class file:

		65531	sipush 8296
		65534	ldc_w #7842 <String 
VADESUREAY>
		65537	aastore
		65538	dup
		65539	sipush 8297
		65542	ldc_w #7843 
<String VADESUREGUN>
		65545	aastore
		65546	dup
		65547	sipush 
8298
		65550	ldc_w #7844 <String 
MEKTUPBASIMTARIHI>
		65553	aastore
		65554	dup
		65555	sipush 
8299
		65558	ldc_w #7845 <String RISKUNSURU>
		65561	aastore
		65562	putstatic 
#7846 <Field tr.com.cs.core.bagkeys.CoreBagKeyNames>bagKeyNames 
java.lang.String[]>
		65565	return

Comment 5 Philipe Mulet CLA 2002-06-04 10:29:09 EDT
Good, we can close this, since it is a bug in javac implementations. They 
should check it.
Comment 6 Olivier Thomann CLA 2002-06-04 11:23:16 EDT
Indeed this is clearly spec'd in the VM 
specs:
http://java.sun.com/docs/books/vmspec/html/ClassFile.doc.html#6253
If you 
replace your code with the second attachment, javac reports:
CoreBagKeyNames.java:10142: 
code too large for try statement
} catch(RuntimeException e) {
  ^
1 error
So they do check 
it when a try/catch is used. According to the specs, our behavior is ok.
Comment 7 Olivier Thomann CLA 2002-06-04 11:25:36 EDT
Created attachment 1226 [details]
Defining class  with a try/catch statement