Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » The code for the static initializer is exceeding the 65535 bytes limit
The code for the static initializer is exceeding the 65535 bytes limit [message #889486] Tue, 19 June 2012 05:26 Go to next message
frank fotso is currently offline frank fotso
Messages: 91
Registered: May 2012
Member
hi,

i have the following error : The code for the static initializer is exceeding the 65535 bytes limit , i think coming from the fact that the grammar is too big.
this is my .mwe2 file
  module org.xtext.example.System

import org.eclipse.emf.mwe.utils.*
import org.eclipse.xtext.generator.*
import org.eclipse.xtext.ui.generator.*

var grammarURI = "classpath:/org/xtext/example/System.xtext"
var file.extensions = "sys1"
var projectName = "org.xtext.example.system"
var runtimeProject = "../${projectName}"

Workflow {
	bean = StandaloneSetup {
		scanClassPath  = true
		platformUri = "${runtimeProject}/.."
		registerGeneratedEPackage = "SystemSparcClockMcu.SystemSparcClockMcuPackage"
	
		// registerGenModelFile = "platform:/resource/ProjectSys1/model/system_sparc_5607.genmodel"
	
	}
    
    
    

	component = DirectoryCleaner {
		directory = "${runtimeProject}/src-gen"
	}

	component = DirectoryCleaner {
		directory = "${runtimeProject}.ui/src-gen"
	}

	component = Generator {
		pathRtProject = runtimeProject
		pathUiProject = "${runtimeProject}.ui"
		projectNameRt = projectName
		projectNameUi = "${projectName}.ui"
		language = {
			uri = grammarURI
			fileExtensions = file.extensions

			// Java API to access grammar elements (required by several other fragments)
			fragment = grammarAccess.GrammarAccessFragment {}

			// generates Java API for the generated EPackages
			// fragment = ecore.EcoreGeneratorFragment {}

			// the serialization component
			fragment = parseTreeConstructor.ParseTreeConstructorFragment {}

			// a custom ResourceFactory for use with EMF 
			fragment = resourceFactory.ResourceFactoryFragment {
				fileExtensions = file.extensions
			}

			// the Antlr parser
			fragment = parser.antlr.XtextAntlrGeneratorFragment {
				options = {
                classSplitting=true
                fieldsPerClass = "500" 
               }

			}

			// the Ecore2Xtext specific terminal converter
			fragment = ecore2xtext.Ecore2XtextValueConverterServiceFragment {}

			// java-based API for validation 
			fragment = validation.JavaValidatorFragment {
			// composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
			// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
			}

			// scoping and exporting API
			fragment = scoping.ImportURIScopingFragment {}
			fragment = exporting.SimpleNamesFragment {}

			// scoping and exporting API 

			// fragment = scoping.ImportNamespacesScopingFragment {}
			// fragment = exporting.QualifiedNamesFragment {}


			// formatter API 
			fragment = ecore2xtext.FormatterFragment {}

			// labeling API 
			fragment = labeling.LabelProviderFragment {}

			// outline API 
            fragment = outline.OutlineTreeProviderFragment {}
            fragment = outline.QuickOutlineFragment {}

			// java-based API for content assistance 
			fragment = contentAssist.JavaBasedContentAssistFragment {}

			// antlr parser generator tailored for content assist 
			fragment = parser.antlr.XtextAntlrUiGeneratorFragment {
				options = {
              classSplitting=true
          fieldsPerClass = "500" 
                }

			}

			// provides a compare view
            fragment = compare.CompareFragment {
                fileExtensions = file.extensions
            }

			fragment = builder.BuilderIntegrationFragment {}

			// project wizard (optional) 

			// fragment = projectWizard.SimpleProjectWizardFragment {
			//		generatorProjectName = "${projectName}.generator" 
			//		modelFileExtension = file.extensions
			// }

			// quickfix API 
			fragment = quickfix.QuickfixProviderFragment {}
		}
	}
}
 


i don't know how to fix it , some says tahat i need to split ma grammar but i cant' then the only way is to modify the lexer or the .mwe2 file , but i have try by adding this fieldsPerClass = "500" to the
fragment= parser.antlr.XtextAntlrGeneratorFragment and also to the
fragment = parser.antlr.XtextAntlrUiGeneratorFragment

but i still have the same error.
i'm using eclipse-SDK-3.7.1- and xtext-2.2.1-win32

Best regard ,
Frank
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #889713 is a reply to message #889486] Tue, 19 June 2012 09:57 Go to previous messageGo to next message
frank fotso is currently offline frank fotso
Messages: 91
Registered: May 2012
Member
any suggestion are welcome.
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #889833 is a reply to message #889713] Tue, 19 June 2012 16:24 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian Zarnekow
Messages: 2809
Registered: July 2009
Senior Member
Am 19.06.12 15:57, schrieb frank fotso:
> any suggestion are welcome.

You'll have to play with fieldsPerClass and methodsPerClass, e.g. 200
fields and 500 methods per class should do the trick.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #889895 is a reply to message #889833] Wed, 20 June 2012 03:51 Go to previous messageGo to next message
frank fotso is currently offline frank fotso
Messages: 91
Registered: May 2012
Member
i have try to modify the
parser.antlr.XtextAntlrGeneratorFragment
and parser.antlr.XtextAntlrUiGeneratorFragment by putting this in the 2 classes,

options = {
// backtrack = true
classSplitting=true
fieldsPerClass = "500"
methodsPerClass= "500"
}


but i still have the same error occuring.
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #889897 is a reply to message #889895] Wed, 20 June 2012 03:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6130
Registered: July 2009
Senior Member
And did you do what sebastian said: setting the values to 200 or 100 ...
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #889899 is a reply to message #889895] Wed, 20 June 2012 04:03 Go to previous messageGo to next message
frank fotso is currently offline frank fotso
Messages: 91
Registered: May 2012
Member
so i have this mwe2 file after replacing tthe codes of the 2 classes:


 module org.xtext.example.System2

import org.eclipse.emf.mwe.utils.*
import org.eclipse.xtext.generator.*
import org.eclipse.xtext.ui.generator.*

var grammarURI = "classpath:/org/xtext/example/System2.xtext"
var file.extensions = "sys2"
var projectName = "org.xtext.example.system2"
var runtimeProject = "../${projectName}"

Workflow {
	bean = StandaloneSetup {
		scanClassPath  = true
		platformUri = "${runtimeProject}/.."
		registerGeneratedEPackage = "SystemSparcClockMcu.SystemSparcClockMcuPackage"
	
		// registerGenModelFile = "platform:/resource/ProjectSys1/model/system_sparc_5607.genmodel"
	
	}

	component = DirectoryCleaner {
		directory = "${runtimeProject}/src-gen"
	}

	component = DirectoryCleaner {
		directory = "${runtimeProject}.ui/src-gen"
	}

	component = Generator {
		pathRtProject = runtimeProject
		pathUiProject = "${runtimeProject}.ui"
		projectNameRt = projectName
		projectNameUi = "${projectName}.ui"
		language = {
			uri = grammarURI
			fileExtensions = file.extensions

			// Java API to access grammar elements (required by several other fragments)
			fragment = grammarAccess.GrammarAccessFragment {}

			// generates Java API for the generated EPackages
			// fragment = ecore.EcoreGeneratorFragment {}

			// the serialization component
			fragment = parseTreeConstructor.ParseTreeConstructorFragment {}

			// a custom ResourceFactory for use with EMF 
			fragment = resourceFactory.ResourceFactoryFragment {
				fileExtensions = file.extensions
			}

			// the Antlr parser
			fragment = parser.antlr.XtextAntlrGeneratorFragment {
				options = {
			 // backtrack = true
              classSplitting=true
               fieldsPerClass = "1200" 
               methodsPerClass= "1200" 
                }
			}

			// the Ecore2Xtext specific terminal converter
			fragment = ecore2xtext.Ecore2XtextValueConverterServiceFragment {}

			// java-based API for validation 
			fragment = validation.JavaValidatorFragment {
			// composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
			// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
			}

			// scoping and exporting API
			fragment = scoping.ImportURIScopingFragment {}
			fragment = exporting.SimpleNamesFragment {}

			// scoping and exporting API 

			// fragment = scoping.ImportNamespacesScopingFragment {}
			// fragment = exporting.QualifiedNamesFragment {}


			// formatter API 
			fragment = ecore2xtext.FormatterFragment {}

			// labeling API 
			fragment = labeling.LabelProviderFragment {}

			// outline API 
            fragment = outline.OutlineTreeProviderFragment {}
            fragment = outline.QuickOutlineFragment {}

			// java-based API for content assistance 
			fragment = contentAssist.JavaBasedContentAssistFragment {}

			// antlr parser generator tailored for content assist 
			fragment = parser.antlr.XtextAntlrUiGeneratorFragment {
				options = {
			 // backtrack = true
              classSplitting=true
               fieldsPerClass = "1200" 
               methodsPerClass= "1200" 
                }
			}

			// provides a compare view
            fragment = compare.CompareFragment {
                fileExtensions = file.extensions
            }

			fragment = builder.BuilderIntegrationFragment {}

			// project wizard (optional) 

			// fragment = projectWizard.SimpleProjectWizardFragment {
			//		generatorProjectName = "${projectName}.generator" 
			//		modelFileExtension = file.extensions
			// }

			// quickfix API 
			fragment = quickfix.QuickfixProviderFragment {}
		}
	}
}
  
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #889902 is a reply to message #889899] Wed, 20 June 2012 04:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6130
Registered: July 2009
Senior Member
No. I said 100 or 200
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #889908 is a reply to message #889902] Wed, 20 June 2012 04:20 Go to previous messageGo to next message
frank fotso is currently offline frank fotso
Messages: 91
Registered: May 2012
Member
i have change as you propose but still the same :

 module org.xtext.example.System2

import org.eclipse.emf.mwe.utils.*
import org.eclipse.xtext.generator.*
import org.eclipse.xtext.ui.generator.*

var grammarURI = "classpath:/org/xtext/example/System2.xtext"
var file.extensions = "sys2"
var projectName = "org.xtext.example.system2"
var runtimeProject = "../${projectName}"

Workflow {
	bean = StandaloneSetup {
		scanClassPath  = true
		platformUri = "${runtimeProject}/.."
		registerGeneratedEPackage = "SystemSparcClockMcu.SystemSparcClockMcuPackage"
	
		// registerGenModelFile = "platform:/resource/ProjectSys1/model/system_sparc_5607.genmodel"
	
	}

	component = DirectoryCleaner {
		directory = "${runtimeProject}/src-gen"
	}

	component = DirectoryCleaner {
		directory = "${runtimeProject}.ui/src-gen"
	}

	component = Generator {
		pathRtProject = runtimeProject
		pathUiProject = "${runtimeProject}.ui"
		projectNameRt = projectName
		projectNameUi = "${projectName}.ui"
		language = {
			uri = grammarURI
			fileExtensions = file.extensions

			// Java API to access grammar elements (required by several other fragments)
			fragment = grammarAccess.GrammarAccessFragment {}

			// generates Java API for the generated EPackages
			// fragment = ecore.EcoreGeneratorFragment {}

			// the serialization component
			fragment = parseTreeConstructor.ParseTreeConstructorFragment {}

			// a custom ResourceFactory for use with EMF 
			fragment = resourceFactory.ResourceFactoryFragment {
				fileExtensions = file.extensions
			}

			// the Antlr parser
			fragment = parser.antlr.XtextAntlrGeneratorFragment {
				options = {
			 // backtrack = true
              classSplitting=true
               fieldsPerClass = "1200" 
               methodsPerClass= "1200" 
                }
			}

			// the Ecore2Xtext specific terminal converter
			fragment = ecore2xtext.Ecore2XtextValueConverterServiceFragment {}

			// java-based API for validation 
			fragment = validation.JavaValidatorFragment {
			// composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
			// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
			}

			// scoping and exporting API
			fragment = scoping.ImportURIScopingFragment {}
			fragment = exporting.SimpleNamesFragment {}

			// scoping and exporting API 

			// fragment = scoping.ImportNamespacesScopingFragment {}
			// fragment = exporting.QualifiedNamesFragment {}


			// formatter API 
			fragment = ecore2xtext.FormatterFragment {}

			// labeling API 
			fragment = labeling.LabelProviderFragment {}

			// outline API 
            fragment = outline.OutlineTreeProviderFragment {}
            fragment = outline.QuickOutlineFragment {}

			// java-based API for content assistance 
			fragment = contentAssist.JavaBasedContentAssistFragment {}

			// antlr parser generator tailored for content assist 
			fragment = parser.antlr.XtextAntlrUiGeneratorFragment {
				options = {
			 // backtrack = true
              classSplitting=true
               fieldsPerClass = "1200" 
               methodsPerClass= "1200" 
                }
			}

			// provides a compare view
            fragment = compare.CompareFragment {
                fileExtensions = file.extensions
            }

			fragment = builder.BuilderIntegrationFragment {}

			// project wizard (optional) 

			// fragment = projectWizard.SimpleProjectWizardFragment {
			//		generatorProjectName = "${projectName}.generator" 
			//		modelFileExtension = file.extensions
			// }

			// quickfix API 
			fragment = quickfix.QuickfixProviderFragment {}
		}
	}
}
 

i have even try by changing the 200 by 100 , but still the same problem . The ile si too big for me to upload it here.
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #889910 is a reply to message #889908] Wed, 20 June 2012 04:32 Go to previous messageGo to next message
frank fotso is currently offline frank fotso
Messages: 91
Registered: May 2012
Member
my file is too large since i have generated my grammar from an XSD which is very very large , the file is doing about 6 or 7 mega , can you just give an email , such that i can send the file directly to you?

looking at the error my problem is the " public class InternalSystem2Lexer extends Lexer" which is underlined in red
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #889911 is a reply to message #889910] Wed, 20 June 2012 04:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6130
Registered: July 2009
Senior Member
Sounds like too few memory
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #889917 is a reply to message #889911] Wed, 20 June 2012 04:56 Go to previous messageGo to next message
frank fotso is currently offline frank fotso
Messages: 91
Registered: May 2012
Member
too few memory from the computer i used or the java heap set up in eclipse?
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #889919 is a reply to message #889917] Wed, 20 June 2012 04:59 Go to previous messageGo to next message
frank fotso is currently offline frank fotso
Messages: 91
Registered: May 2012
Member
i have 3 giga memory in my computer and it is a dual core , and i also change the java heap of eclipse to 512M
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #889943 is a reply to message #889919] Wed, 20 June 2012 06:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6130
Registered: July 2009
Senior Member
Hi,

i think of the memory the workflow gets (run config)
as well as the time it needs
(i think you can somehow pass a conversion timeout to antlr)

~Christian
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #901729 is a reply to message #889486] Tue, 14 August 2012 07:18 Go to previous messageGo to next message
Vil Lpz is currently offline Vil Lpz
Messages: 24
Registered: April 2012
Junior Member
Hello.

I have exactly the same problem as frank

This is my mwe2:

I enclose my grammar in this post

I took several days with this and can not find solution, Any help will be welcome.

Thank you.

Greetings.

module mymw.ideal2dsl.GenerateIdeal2Dsl

import org.eclipse.emf.mwe.utils.*
import org.eclipse.xtext.generator.*
import org.eclipse.xtext.ui.generator.*

var grammarURI = "classpath:/mymw/ideal2dsl/Ideal2Dsl.xtext"
var file.extensions = "ideal"
var projectName = "mymw.ideal2dsl"
var runtimeProject = "../${projectName}"

Workflow {
    bean = StandaloneSetup {
        scanClassPath = true
        platformUri = "${runtimeProject}/.."
        // The following two lines can be removed, if Xbase is not used.
        registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage"
        registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
    }

    component = DirectoryCleaner {
        directory = "${runtimeProject}/src-gen"
    }

    component = DirectoryCleaner {
        directory = "${runtimeProject}.ui/src-gen"
    }

    component = Generator {
        pathRtProject = runtimeProject
        pathUiProject = "${runtimeProject}.ui"
        pathTestProject = "${runtimeProject}.tests"
        projectNameRt = projectName
        projectNameUi = "${projectName}.ui"
        language = {
            uri = grammarURI
            fileExtensions = file.extensions

            // Java API to access grammar elements (required by several other fragments)
            fragment = grammarAccess.GrammarAccessFragment {}

            // generates Java API for the generated EPackages
            fragment = ecore.EcoreGeneratorFragment {
            // referencedGenModels = "
            //  platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel,
            //  platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.genmodel
            // "
            }

            // Serializer 2.0
            fragment = serializer.SerializerFragment {
            	generateStub = false
            }
            
            // the serialization component (1.0)
            // fragment = parseTreeConstructor.ParseTreeConstructorFragment {}

            // a custom ResourceFactory for use with EMF
            fragment = resourceFactory.ResourceFactoryFragment {
                fileExtensions = file.extensions
            }

            // The antlr parser generator fragment.
            fragment = parser.antlr.XtextAntlrGeneratorFragment {
            //  options = {
            //      backtrack = true
            //  }
			   /*antlrParam = "-Xmaxinlinedfastates" antlrParam = "100000"
			   antlrParam = "-Xmaxswitchcaselabels" antlrParam = "30000"
			   antlrParam = "-Xminswitchalts" antlrParam="1"   */         
           	 	options = {
					classSplitting = true
	      			fieldsPerClass = "100"   
	      			methodsPerClass  = "200"    
	      		}      
            }

            // java-based API for validation
            fragment = validation.JavaValidatorFragment {
            //    composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
            //    composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
            }

            // scoping and exporting API
            // fragment = scoping.ImportURIScopingFragment {}
            // fragment = exporting.SimpleNamesFragment {}

            // scoping and exporting API
            fragment = scoping.ImportNamespacesScopingFragment {}
            fragment = exporting.QualifiedNamesFragment {}
            fragment = builder.BuilderIntegrationFragment {}

            // generator API
            fragment = generator.GeneratorFragment {
                generateMwe = false
                generateJavaMain = false
            }

            // formatter API
            fragment = formatting.FormatterFragment {}

            // labeling API
            fragment = labeling.LabelProviderFragment {}

            // outline API
            fragment = outline.OutlineTreeProviderFragment {}
            fragment = outline.QuickOutlineFragment {}

            // quickfix API
            fragment = quickfix.QuickfixProviderFragment {}

            // content assist API
            fragment = contentAssist.JavaBasedContentAssistFragment {}

            // generates a more lightweight Antlr parser and lexer tailored for content assist
            fragment = parser.antlr.XtextAntlrUiGeneratorFragment {
            	/*antlrParam = "-Xmaxinlinedfastates" antlrParam = "100000"
   				antlrParam = "-Xmaxswitchcaselabels" antlrParam = "30000"
   				antlrParam = "-Xminswitchalts" antlrParam="1"*/
           	 	options = {
					classSplitting = true
	      			fieldsPerClass = "100"     
	      			methodsPerClass  = "200"    
	      		}           	
            }

            // generates junit test support classes into Generator#pathTestProject
            fragment = junit.Junit4Fragment {}

            // project wizard (optional)
            // fragment = projectWizard.SimpleProjectWizardFragment {
            //      generatorProjectName = "${projectName}"
            //      modelFileExtension = file.extensions
            // }

            // rename refactoring
            fragment = refactoring.RefactorElementNameFragment {}

            // provides the necessary bindings for java types integration
            fragment = types.TypesGeneratorFragment {}

            // generates the required bindings only if the grammar inherits from Xbase
            fragment = xbase.XbaseGeneratorFragment {}

            // provides a preference page for template proposals
            fragment = templates.CodetemplatesGeneratorFragment {}

            // provides a compare view
            fragment = compare.CompareFragment {
                 fileExtensions = file.extensions
            }

        }
    }
}
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #907030 is a reply to message #901729] Mon, 03 September 2012 03:17 Go to previous messageGo to next message
Vil Lpz is currently offline Vil Lpz
Messages: 24
Registered: April 2012
Junior Member
Any idea?

Thanks!
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #907100 is a reply to message #907030] Mon, 03 September 2012 05:39 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian Zarnekow
Messages: 2809
Registered: July 2009
Senior Member
Am 03.09.12 09:17, schrieb Vil Lpz:
> Any idea?
>
> Thanks!

Could you please file a ticket. Thanks.

Best regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #907197 is a reply to message #907100] Mon, 03 September 2012 09:56 Go to previous messageGo to next message
Vil Lpz is currently offline Vil Lpz
Messages: 24
Registered: April 2012
Junior Member
Hello.

I just did.

Thanks for your attention.

A greeting.
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #907335 is a reply to message #907197] Mon, 03 September 2012 15:38 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian Zarnekow
Messages: 2809
Registered: July 2009
Senior Member
Am 03.09.12 15:56, schrieb Vil Lpz:
> Hello.
>
> I just did.
>
> Thanks for your attention.
>
> A greeting.

I can reproduce the issue. Thanks for the ticket.

Best regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #923907 is a reply to message #907335] Wed, 26 September 2012 05:50 Go to previous messageGo to next message
Vil Lpz is currently offline Vil Lpz
Messages: 24
Registered: April 2012
Junior Member
Hello Sebastian.

I'm still mulling over this problem and can not find a solution. I´m try to split the grammar in two different files, but the problem still appears .... (Enclosed to this post is my mwe2 file and the grammar files.)

Any idea how I can generate my grammar without errors?

Any advice is welcome.

Thanks for the support.

A greeting.
  • Attachment: MyDsl.zip
    (Size: 11.90KB, Downloaded 53 times)
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #924151 is a reply to message #923907] Wed, 26 September 2012 11:02 Go to previous messageGo to next message
Vil Lpz is currently offline Vil Lpz
Messages: 24
Registered: April 2012
Junior Member
Hello again.

Attached to this post is my grammar in a single file and the mwe2.

If you go to line 641 of xtext file and uncomment and that line (or any of the others that are commented) is when the error "The code for the static initializer is exceeding the 65535 bytes limit" appears ...

I took several days mulling over this and I don't know what can I do to generate all my grammar without problems... Confused

Any help is welcome.

Thank you!
Virgilio
  • Attachment: xtext.rar
    (Size: 9.83KB, Downloaded 64 times)
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #924902 is a reply to message #924151] Thu, 27 September 2012 04:11 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian Zarnekow
Messages: 2809
Registered: July 2009
Senior Member
Am 26.09.12 17:02, schrieb Vil Lpz:
> Hello again.
>
> Attached to this post is my grammar in a single file and the mwe2.
>
> If you go to line 641 of xtext file and uncomment and that line (or any of the others that are commented) is when the error "The code for the static initializer is exceeding the 65535 bytes limit" appears ...
>
> I took several days mulling over this and I don't know what can I do to generate all my grammar without problems... :?
>
> Any help is welcome.
>
> Thank you!
> Virgilio
>

Hi Vil,

there are some suspicuous parts in your grammar:

TdType - the unordered group has to be put into parentheses, though I'm
not sure that your really want an unordered group here or just a loop
over an alternative:

(
'>'

/*
* Content Model
* ( PCDATA | output? | span* | image* | p* )
*/

( tdMix += TdMix* & text = (StringPart | IdealExpressionPart) )
'</td>'
)

This construct will lead to an ambiguity in the UI grammar. Therefore I
recommend to rewrite it to something along these lines:

( tdMix += TdMix*
| text = (StringPart | IdealExpressionPart)
) // | Expresion // ojo en este expresion faltan los ${...}

This matches the patterns that you applied in other parts of your grammar.

SelectContent - the rule matches the empty input. Better make the rule
call optional and rewrite it to something like:
SelectContent:
{SelectContent}
/*
* Content Model
* ( label? , ( ( item | separator )* | repeat )? )
*/

label=LabelType (
selectMix+=SelectMix+ repeat=RepeatType?
| repeat=RepeatType selectMix+=SelectMix*
)?
| selectMix+=SelectMix+ repeat=RepeatType?
| repeat=RepeatType selectMix+=SelectMix*
;
Please note that it's often better to manually transform unordered
groups if they are sufficiently small (2 or 3 elements). Also note that
your SelectContent (and my rewritten version) does not seem to match the
DTD snippet in the comment.

In order to split the generated 17MB file properly, you have to apply
the following substitutions by means of regular expressions:

search for: "class DFA\d+ extends DFA \{"
replace with: "" (empty string)

search for: "(static final String DFA(\d+)_eotS =)"
replace with: "static class DFA$2 extends HackedDFA {\n $1"

search for: "this\.recognizer = recognizer;"
replace with: "super(recognizer);"

Add this method to the IntegernalXXXParser1 class (at the top):

RecognizerSharedState getRecognizerSharedState() {
return state;
}

and add this class to UI Parser file:

class HackedDFA extends DFA {

protected RecognizerSharedState state;
protected XXXGrammarAccess grammarAccess;

HackedDFA(BaseRecognizer recognizer) {
this.recognizer = recognizer;
this.grammarAccess =
((IntegernalXXXParser1)recognizer).grammarAccess;
this.state =
((IntegernalXXXParser1)recognizer).getRecognizerSharedState();
}

protected IUnorderedGroupHelper getUnorderedGroupHelper() {
return getRecognizer().getUnorderedGroupHelper();
}
}

where XXX is the name of your language.

If you do frequent changes in your grammar, I recommend to write a small
IGeneratorFragment that performs these steps automatically and use that
one in the MWE workflow.

Please not that you most likely cannot open the generated Parser file
with the Eclipse Java editor and try to perform those steps. The text
editor works fine, though you probably have to ignore some OutOfMemory
errors from Eclipse.

Since these extraction steps are easy to automate, I confident that
we'll be able to provide them with Eclipse Kepler as part of the class
splitting.

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #925244 is a reply to message #924902] Thu, 27 September 2012 10:28 Go to previous messageGo to next message
Vil Lpz is currently offline Vil Lpz
Messages: 24
Registered: April 2012
Junior Member
Hello Sebastian, thanks a lot for your time.

Thanks a lot for the grammar advices. I't my first serious grammar and I supose I have mistakes, so any advice is very welcome, even about the style.

I tried your solution. But isn't worked ... I try to make the changes only the UI project and the grammar and UI project both. But the result is that when I execute the UI project and try to use the context proposal (CTRL+Space) I obtain the following error:

!SESSION 2012-09-27 13:49:52.247 -----------------------------------------------
eclipse.buildId=I20120608-1400
java.version=1.6.0_25
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=es_ES
Framework arguments:  -product org.eclipse.sdk.ide
Command-line arguments:  -product org.eclipse.sdk.ide -data C:\Users\virgilio.garcia\Desktop\WS/../runtime-EclipseApplication -dev file:C:/Users/virgilio.garcia/Desktop/WS/.metadata/.plugins/org.eclipse.pde.core/Eclipse Application/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog

!ENTRY org.eclipse.ui 2 2 2012-09-27 13:50:17.076
!MESSAGE Invalid property category path: ValidationPropertiesPage (bundle: org.eclipse.wst.xml.ui, propertyPage: org.eclipse.wst.xml.ui.propertyPage.project.validation)

!ENTRY org.eclipse.e4.ui.workbench 4 0 2012-09-27 13:50:34.652
!MESSAGE 
!STACK 0
org.eclipse.e4.core.di.InjectionException: org.eclipse.core.commands.ExecutionException: While executing the action, an exception occurred
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:229)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:210)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:131)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:171)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:276)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:494)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:545)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:366)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.access$0(KeyBindingDispatcher.java:313)
	at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:82)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1262)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1104)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1100)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1521)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4640)
	at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:345)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4528)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4976)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2546)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3756)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1022)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:916)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:585)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:540)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
Caused by: org.eclipse.core.commands.ExecutionException: While executing the action, an exception occurred
	at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:124)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:76)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	... 48 more
Caused by: com.google.inject.ProvisionException: Guice provision errors:

1) Error in custom provider, java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
  at mymw.ideal2dsl.ui.AbstractIdeal2DslUiModule.configureContentAssistLexerProvider(AbstractIdeal2DslUiModule.java:123)
  while locating mymw.ideal2dsl.ui.contentassist.antlr.internal.InternalIdeal2DslLexer
  while locating org.eclipse.xtext.ui.editor.contentassist.antlr.internal.Lexer annotated with @com.google.inject.name.Named(value=org.eclipse.xtext.ui.editor.contentassist.antlr.internal.Lexer.CONTENT_ASSIST)
    for field at org.eclipse.xtext.ui.editor.contentassist.antlr.ParserBasedContentAssistContextFactory$StatefulFactory.lexer(Unknown Source)
  while locating org.eclipse.xtext.ui.editor.contentassist.antlr.ParserBasedContentAssistContextFactory$StatefulFactory

1 error
	at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:987)
	at org.eclipse.xtext.ui.editor.contentassist.antlr.ParserBasedContentAssistContextFactory.create(ParserBasedContentAssistContextFactory.java:577)
	at org.eclipse.xtext.ui.editor.contentassist.CompletionProposalComputer.exec(CompletionProposalComputer.java:48)
	at org.eclipse.xtext.ui.editor.contentassist.CompletionProposalComputer.exec(CompletionProposalComputer.java:1)
	at org.eclipse.xtext.util.concurrent.AbstractReadWriteAcces.readOnly(AbstractReadWriteAcces.java:32)
	at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:78)
	at org.eclipse.xtext.ui.editor.contentassist.XtextContentAssistProcessor.computeCompletionProposals(XtextContentAssistProcessor.java:68)
	at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1839)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:566)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$16(CompletionProposalPopup.java:563)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:498)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:492)
	at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1665)
	at org.eclipse.jface.text.source.SourceViewer.doOperation(SourceViewer.java:932)
	at org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1507)
	at org.eclipse.ui.texteditor.ContentAssistAction$1.run(ContentAssistAction.java:82)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.texteditor.ContentAssistAction.run(ContentAssistAction.java:80)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:119)
	... 54 more
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at org.eclipse.xtext.parser.antlr.LexerProvider.get(LexerProvider.java:46)
	at org.eclipse.xtext.parser.antlr.LexerProvider.get(LexerProvider.java:1)
	at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
	at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:54)
	at com.google.inject.internal.SingleFieldInjector.inject(SingleFieldInjector.java:53)
	at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:110)
	at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:94)
	at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
	at com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:978)
	at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1024)
	at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:974)
	... 74 more
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at org.eclipse.xtext.parser.antlr.LexerProvider.get(LexerProvider.java:43)
	... 84 more
Caused by: java.lang.ClassCastException: mymw.ideal2dsl.ui.contentassist.antlr.internal.InternalIdeal2DslLexer cannot be cast to mymw.ideal2dsl.ui.contentassist.antlr.internal.InternalIdeal2DslParser1
	at mymw.ideal2dsl.ui.contentassist.antlr.internal.HackedDFA.<init>(InternalIdeal2DslParser.java:5760)
	at mymw.ideal2dsl.ui.contentassist.antlr.internal.InternalIdeal2DslLexer$DFA8.<init>(InternalIdeal2DslLexer.java:10041)
	at mymw.ideal2dsl.ui.contentassist.antlr.internal.InternalIdeal2DslLexer.<init>(InternalIdeal2DslLexer.java:8894)
	at mymw.ideal2dsl.ui.contentassist.antlr.internal.InternalIdeal2DslLexer.<init>(InternalIdeal2DslLexer.java:318)
	... 89 more


I tested with 2 xtext revisions (2.3.1 and 2.2.1) in 2 different eclipses and the problem is the same.

Any idea about can it happen?

Thanks a lot for the support.

Greetings.
Re: The code for the static initializer is exceeding the 65535 bytes limit [message #1037323 is a reply to message #889486] Tue, 09 April 2013 08:20 Go to previous message
Sezgin Aytac is currently offline Sezgin Aytac
Messages: 1
Registered: April 2013
Location: Turkey
Junior Member
Hi Frank,
If you are still have this problem, you can work around
by moving the static tokenNames declaration to getTokenNames()
method. I tried the suggestions on the forums (setting
fieldsPerClass and methodsPerClass, etc), but I couldn' t
solved except this manual work around. If I automate this
replacement, I' ll share also.
Best regards,
Sezgin

Delete
private static final String[] tokenNames = new String[] {
// a long token list here
};

Replace
public String[] getTokenNames() { return InternalNgiDslParser.tokenNames; }
with
public String[] getTokenNames() {
return new String[] {
// a long token list here
};
}
Previous Topic:How to define an abstract behavior in the ".dmodel" file?
Next Topic:Confusion about completion proposals
Goto Forum:
  


Current Time: Thu Jul 24 21:40:51 EDT 2014

Powered by FUDForum. Page generated in 0.03408 seconds