Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 323346

Summary: NegativeArraySizeException thrown during serialization
Product: [Modeling] TMF Reporter: Stefan Holzknecht <s.holzknecht>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: sebastian.zarnekow
Version: 0.7.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Stefan Holzknecht CLA 2010-08-23 02:25:20 EDT
Build Identifier: 20100617-1415

When serializing I get an error:
!ENTRY com.intershop.enfinity.studio.emf.opexpression 4 -1 2010-08-23 08:11:55.776
!MESSAGE An exception occured: null
!STACK 0
java.lang.NegativeArraySizeException
	at java.lang.AbstractStringBuilder.<init>(AbstractStringBuilder.java:45)
	at java.lang.StringBuilder.<init>(StringBuilder.java:80)
	at org.eclipse.xtext.parsetree.reconstr.impl.ValueSerializer.serialize(ValueSerializer.java:64)
	at org.eclipse.xtext.parsetree.reconstr.impl.ValueSerializer.serializeAssignedValue(ValueSerializer.java:82)
	at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeConstructor$AssignmentToken.serializeInternal(AbstractParseTreeConstructor.java:271)
	at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeConstructor$AbstractToken.serialize(AbstractParseTreeConstructor.java:155)
	at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeConstructor.write(AbstractParseTreeConstructor.java:739)
	at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeConstructor.write(AbstractParseTreeConstructor.java:734)
	at org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeConstructor.serializeSubtree(AbstractParseTreeConstructor.java:721)
	at org.eclipse.xtext.parsetree.reconstr.Serializer.serialize(Serializer.java:55)
	at org.eclipse.xtext.parsetree.reconstr.Serializer.serialize(Serializer.java:71)

This is caused because method org.eclipse.xtext.parsetree.impl.AbstractNodeImpl.getTotalLength() return -1. When debugging I got such a LeafNode: org.eclipse.xtext.parsetree.impl.LeafNodeImpl@1c4317c (totalOffset: 0, totalLine: 0, totalLength: -1) (text: myTest, feature: null, hidden: false).


Reproducible: Always
Comment 1 Sebastian Zarnekow CLA 2010-08-23 03:34:04 EDT
How do you create your model?
Comment 2 Stefan Holzknecht CLA 2010-08-23 03:43:27 EDT
(In reply to comment #1)
> How do you create your model?

Because I need the model outside the editor I use org.eclipse.xtext.parser.AbstractParser.parse(Reader).
Comment 3 Sebastian Zarnekow CLA 2010-08-23 03:48:10 EDT
Never do that. Create a resourceSet instead and use resourceSet#getResource or resourceSet#createResource. See here: http://wiki.eclipse.org/Xtext/FAQ#How_do_I_load_my_model_in_a_standalone_Java_application_.3F
Comment 4 Karsten Thoms CLA 2017-09-19 16:13:07 EDT
Closing bug which were set to RESOLVED before Eclipse Neon.0.