Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Error: The code for the static initializer is exceeding the 65535 bytes limit
Error: The code for the static initializer is exceeding the 65535 bytes limit [message #1797710] Mon, 05 November 2018 09:20 Go to next message
Eclipse UserFriend
Hello,

I am working on a fairly large grammar. After adding some more rules and running the workflow I get the above mentioned error in the Internal<myDSLName>Parser class.

I have tried moving the static tokenNames declaration to the getTokenNames() method (suggested by Sezgin).

And I have tried using the class splitting feature with the following options in the workflow:
language = StandardLanguage {
	// ... name and stuff

	parserGenerator = {
		options = {
			classSplitting = true
			fieldsPerClass = "20"
			methodsPerClass = "50"
		}
	}
}

I've tried many different combinations with numbers between 10 and 2000 for the two settings. The class splitting seems to work but the error stays the same.

Does this mean the grammar is too complex/ambiguous or might there be other solutions?

Regards,
Pierce
Re: Error: The code for the static initializer is exceeding the 65535 bytes limit [message #1797732 is a reply to message #1797710] Mon, 05 November 2018 15:40 Go to previous messageGo to next message
Eclipse UserFriend
hi,

did you try do debug org.eclipse.xtext.xtext.generator.parser.antlr.splitting.PartialClassExtractor?
i am not sure if this is a point for splitting.
what is it that makes you having so many token names?

[Updated on: Mon, 05 November 2018 15:41] by Moderator

Re: Error: The code for the static initializer is exceeding the 65535 bytes limit [message #1797776 is a reply to message #1797732] Tue, 06 November 2018 05:22 Go to previous messageGo to next message
Eclipse UserFriend
Hello and thanks for the quick reply.

Actually, after seeing some other grammars on here, I came to realize, the one I am working is not that big. It is only 400 lines and has 138 token names.

What seems to be the problem are the String arrays inside Internal<myDSLName>Parser that are named dfa_<someNumber>s. One of these, static final String[] dfa_13s has more than 9000 entries. Having this array alone in a single class already gives the mentioned error.

What could lead to these generated arrays becoming so huge?

Greetings,
Pierce
Re: Error: The code for the static initializer is exceeding the 65535 bytes limit [message #1797779 is a reply to message #1797776] Tue, 06 November 2018 06:30 Go to previous messageGo to next message
Eclipse UserFriend
can you please open a bug at github.com/eclipse/xtext-core
it looks like the splitter does not split tokennames
=> this is why here it is proposed to do that manually:
https://www.eclipse.org/forums/index.php?t=msg&th=364871&goto=1037323&#msg_1037323
Re: Error: The code for the static initializer is exceeding the 65535 bytes limit [message #1797782 is a reply to message #1797779] Tue, 06 November 2018 06:49 Go to previous messageGo to next message
Eclipse UserFriend
Hello Christian,

I don't think the tokennames are the problem, that's why the suggestion you linked doesn't work for me. As I said, the tokenNames array only contains 138 entries.

But the InternalParser also contains more static String arrays called dfa something. For my current grammar there is a String array called dfa_13s which is initialized with more than 9000 entries. It looks like this:

	static final String[] dfa_13s = {
	        "\1\1\32\uffff\1\2\52\uffff\1\2",
	        "\1\3\11\uffff\1\4\1\5\1\6\1\7\1\10",
	        "",
	        "\1\12\1\uffff\1\11",
	        "\1\12\1\uffff\1\11",
	        "\1\12\1\uffff\1\11",
	        "\1\12\1\uffff\1\11",
	        "\1\12\1\uffff\1\11",
	        "\1\12\1\uffff\1\11",
	        "\1\13",
	        "\1\21\45\uffff\1\22\1\uffff\1\14\1\15\1\16\2\uffff\1\20\16\uffff\1\17",
	        "\1\12",
	        "\1\23\11\uffff\1\24\1\25\1\26\1\27\1\30",
	        "\1\31\11\uffff\1\32\1\33\1\34\1\35\1\36",
	        "\1\37",
	        "\1\40",
	        "\1\42\10\uffff\1\41",
	        "\1\43",
	        "\1\uffff",
	        "\1\45",
	        "\1\45",
	        "\1\45",
	        "\1\45",
	        "\1\45",
	        "\1\45",
	        "\1\54\45\uffff\1\22\1\uffff\1\50\1\47\1\51\1\46\1\uffff\1\53\16\uffff\1\52",
	        "\1\54\45\uffff\1\22\1\uffff\1\50\1\47\1\51\1\46\1\uffff\1\53\16\uffff\1\52",
	        "\1\54\45\uffff\1\22\1\uffff\1\50\1\47\1\51\1\46\1\uffff\1\53\16\uffff\1\52",
	        "\1\54\45\uffff\1\22\1\uffff\1\50\1\47\1\51\1\46\1\uffff\1\53\16\uffff\1\52",
	        "\1\54\45\uffff\1\22\1\uffff\1\50\1\47\1\51\1\46\1\uffff\1\53\16\uffff\1\52",
	        "\1\54\45\uffff\1\22\1\uffff\1\50\1\47\1\51\1\46\1\uffff\1\53\16\uffff\1\52",
	       // [...] and 9000 more lines


Should the class splitter also split these arrays? Or might these huge dfa arrays mean there is something wrong with my grammar?

Cheers,
Pierce

[Updated on: Tue, 06 November 2018 06:51] by Moderator

Re: Error: The code for the static initializer is exceeding the 65535 bytes limit [message #1797784 is a reply to message #1797782] Tue, 06 November 2018 06:59 Go to previous messageGo to next message
Eclipse UserFriend
as said: please open a bug
Re: Error: The code for the static initializer is exceeding the 65535 bytes limit [message #1797788 is a reply to message #1797784] Tue, 06 November 2018 07:24 Go to previous messageGo to next message
Eclipse UserFriend
I created a bug report. A grammar to reproduce this issue is attached to this post.

These options I saw in another thread also didn't help:
component = XtextGenerator {
	configuration = {
		[...]
	}

	language = StandardLanguage {
		[...]

		parserGenerator = {
			antlrParam = "-Xmaxinlinedfastates" antlrParam = "65534"
			antlrParam = "-Xmaxswitchcaselabels" antlrParam = "32000"
			antlrParam = "-Xminswitchalts" antlrParam="1"
		}
	}
}
  • Attachment: MyDsl.xtext
    (Size: 4.59KB, Downloaded 179 times)

[Updated on: Wed, 07 November 2018 07:59] by Moderator

Re: Error: The code for the static initializer is exceeding the 65535 bytes limit [message #1797931 is a reply to message #1797788] Thu, 08 November 2018 12:16 Go to previous messageGo to next message
Eclipse UserFriend
Hey Pierce,

this may be a rather naive question, but does this happen as well if you skip the antlr options?
Do you also set these options in your real project?

Best
Sebastian
Re: Error: The code for the static initializer is exceeding the 65535 bytes limit [message #1798079 is a reply to message #1797931] Mon, 12 November 2018 04:08 Go to previous message
Eclipse UserFriend
Hello Sebastian,

yes, this happens without the options. And no, I don't use them in the project, I just tried them out to fix the error.

The nested unordered groups (&-operator) seem to be causing the complexity which leads to those huge DFA arrays. By following this advice on Stack Overflow I managed to prevent that from happening.

Kind regards,
Pierce

[Updated on: Mon, 12 November 2018 04:08] by Moderator

Previous Topic:[Xbase] Problems with types and scoping in Xbase-based DSL
Next Topic:Xtend generator fails- attributes are not resolved
Goto Forum:
  


Current Time: Sat Jun 14 23:26:35 EDT 2025

Powered by FUDForum. Page generated in 0.05230 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top