Bug 29376 - Remove 65k limit on static data
Summary: Remove 65k limit on static data
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 2.1 M5   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-13 07:22 EST by Oyvind Harboe CLA
Modified: 2003-02-11 09:26 EST (History)
0 users

See Also:


Attachments
Produces unexpected error (477.91 KB, text/plain)
2003-01-13 08:49 EST, Oyvind Harboe CLA
no flags Details
demonstrates differences in class file size limit for static and final (252.09 KB, text/plain)
2003-01-13 08:57 EST, Oyvind Harboe CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Oyvind Harboe CLA 2003-01-13 07:22:05 EST
I'm sampling some data for my application, and I'd like to embed it as a static 
table.

I run into this limit, which it would be nice to have removed.

"The code for the static initializer is exceeding the 65535 bytes limit"

Øyvind
Comment 1 Olivier Thomann CLA 2003-01-13 08:30:17 EST
The problem is that some VMs won't be able to execute your code if we remove
this limit. This is a limitation of the .class file format. The solution is to
split your code into small static methods and then you call these methods inside
your static initializer.
Comment 2 Oyvind Harboe CLA 2003-01-13 08:34:30 EST
>The problem is that some VMs won't be able to execute your code if 
>we remove this limit. This is a limitation of the .class file format. 

I see.

What mislead me to think was a problem in Eclipse is that this limit does not 
exist for non-static initialisations(or if it does, I do not get any error 
messages).

Øyvind
Comment 3 Philipe Mulet CLA 2003-01-13 08:37:48 EST
Pls double check
Comment 4 Oyvind Harboe CLA 2003-01-13 08:41:28 EST
Check: 

// this compiles
private final class A 
// this does not
//private static class A 
{
	final private double[] foo=
	{
	0.000000e+000, 0.000000e+000,
	2.442002e-004, 1.392198e-005
	,4.884005e-004, 2.797402e-005
	,7.326007e-004, 4.228620e-005

.... lots of data follows

Comment 5 Olivier Thomann CLA 2003-01-13 08:43:56 EST
Please attach the whole source. I will investigate.
Comment 6 Oyvind Harboe CLA 2003-01-13 08:49:02 EST
Created attachment 2959 [details]
Produces unexpected error

I'm trying to remove NDA stuff from the testcase I'm uploading and I discovered
this.

I didn't know there was a size limit to .class files.


"The code of method Foo is exceeding the 65535 bytes limit"
Comment 7 Oyvind Harboe CLA 2003-01-13 08:57:06 EST
Created attachment 2961 [details]
demonstrates differences in class file size limit for static and final

See first of lines on how to modify the file to compile when using "final"
instead of "static".
Comment 8 Olivier Thomann CLA 2003-01-13 09:16:58 EST
Ok. The reason why it works when you remove the first static is because you move
the code generation of the first array into a constructor and you keep all other
static fields inside the <clinit>. If you remove all your static fields to have
only instance fields, you will have the same problem.
Compiled 8214 lines in 2266 ms (3624.8 lines/s)
----------
1. ERROR in D:\temp\Foo.java (at line 5)
	public class Foo
	             ^^^
The code of method Foo is exceeding the 65535 bytes limit
----------
1 problem (1 error)

In fact we might want to improve the error message. It should say this is a
constructor.
Your solution is either to move each static fiel initialization in a separate
method and call all these methods inside your static initializer or you
initialize your arrays using a for loop.

Ok to close?
Comment 9 Oyvind Harboe CLA 2003-01-13 09:21:34 EST
>Ok to close?

Yup.

I agree that if anything should be done, it would be to improve the error 
message.

Øyvind
Comment 10 Olivier Thomann CLA 2003-01-13 09:56:58 EST
Error message fixed.
We now distinguish between constructors and methods. I also added the parameters
in the error message.
Fixed and released in 2.1 stream.
Comment 11 David Audel CLA 2003-02-11 09:26:29 EST
Verified.