Bug 241470 - [DOM] AssertionFailedException when setting both FetchType and CascadeType in JPA Details view
Summary: [DOM] AssertionFailedException when setting both FetchType and CascadeType in...
Status: VERIFIED DUPLICATE of bug 234583
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.5 M2   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-20 03:45 EDT by Reto Urfer CLA
Modified: 2008-09-15 12:47 EDT (History)
4 users (show)

See Also:


Attachments
Project I could reproduce the problem with (7.07 KB, application/x-zip-compressed)
2008-07-20 10:24 EDT, Reto Urfer CLA
no flags Details
test project - one failing test (10.63 KB, application/octet-stream)
2008-08-18 13:38 EDT, Karen Butzke CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Reto Urfer CLA 2008-07-20 03:45:50 EDT
Build ID: I20080617-2000

Steps To Reproduce:
1. Create a field 
   private Set<TargetEntity> ref;
   and map it as an association field (OneToOne, OneTomany, ManyToOne or ManyToMany)
2. Set the FetchType to a non-default value in JPA Details view.
3. Select any of the CascadeType options in JPA Details view
   => The cascade type definition is not added to the annotation in the Java file but the toggle in the JPA Details view is selected. The following exception is listed in the ErrorLog view:

eclipse.buildId=I20080617-2000
java.version=1.6.0_06
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_CH
Framework arguments:  -showlocation
Command-line arguments:  -os win32 -ws win32 -arch x86 -data D:\Daten\eclipse34\Test\workspace -showlocation


Error
Sun Jul 20 09:41:00 CEST 2008
Unhandled event loop exception

org.eclipse.core.runtime.AssertionFailedException: assertion failed: 
	at org.eclipse.core.runtime.Assert.isTrue(Assert.java:111)
	at org.eclipse.core.runtime.Assert.isTrue(Assert.java:97)
	at org.eclipse.text.edits.TextEdit.<init>(TextEdit.java:148)
	at org.eclipse.text.edits.ReplaceEdit.<init>(ReplaceEdit.java:36)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteFormatter.shifEdit(ASTRewriteFormatter.java:375)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteFormatter.shifEdit(ASTRewriteFormatter.java:389)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteFormatter.formatNode(ASTRewriteFormatter.java:366)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteFormatter.getFormattedResult(ASTRewriteFormatter.java:184)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.doTextInsert(ASTRewriteAnalyzer.java:1021)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer$ListRewriter.rewriteList(ASTRewriteAnalyzer.java:501)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer$ListRewriter.rewriteList(ASTRewriteAnalyzer.java:435)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.rewriteNodeList(ASTRewriteAnalyzer.java:926)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.visit(ASTRewriteAnalyzer.java:3208)
	at org.eclipse.jdt.core.dom.NormalAnnotation.accept0(NormalAnnotation.java:163)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2478)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.doVisit(ASTRewriteAnalyzer.java:290)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.voidVisitList(ASTRewriteAnalyzer.java:328)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.voidVisit(ASTRewriteAnalyzer.java:322)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.doVisitUnchangedChildren(ASTRewriteAnalyzer.java:335)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.visit(ASTRewriteAnalyzer.java:2005)
	at org.eclipse.jdt.core.dom.FieldDeclaration.accept0(FieldDeclaration.java:279)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2478)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.doVisit(ASTRewriteAnalyzer.java:290)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.voidVisitList(ASTRewriteAnalyzer.java:328)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.voidVisit(ASTRewriteAnalyzer.java:322)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.doVisitUnchangedChildren(ASTRewriteAnalyzer.java:335)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.visit(ASTRewriteAnalyzer.java:1334)
	at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:467)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2478)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.doVisit(ASTRewriteAnalyzer.java:290)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.voidVisitList(ASTRewriteAnalyzer.java:328)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.voidVisit(ASTRewriteAnalyzer.java:322)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.doVisitUnchangedChildren(ASTRewriteAnalyzer.java:335)
	at org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer.visit(ASTRewriteAnalyzer.java:1314)
	at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:209)
	at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2478)
	at org.eclipse.jdt.core.dom.InternalASTRewrite.rewriteAST(InternalASTRewrite.java:93)
	at org.eclipse.jdt.core.dom.AST.rewrite(AST.java:2860)
	at org.eclipse.jdt.core.dom.CompilationUnit.rewrite(CompilationUnit.java:906)
	at org.eclipse.jpt.core.internal.utility.jdt.JDTMember.edit_(JDTMember.java:176)
	at org.eclipse.jpt.core.internal.utility.jdt.JDTMember.edit(JDTMember.java:142)
	at org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter.edit(MemberAnnotationElementAdapter.java:71)
	at org.eclipse.jpt.core.internal.utility.jdt.MemberAnnotationElementAdapter.setValue(MemberAnnotationElementAdapter.java:51)
	at org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter.setValue(ShortCircuitAnnotationElementAdapter.java:91)
	at org.eclipse.jpt.core.internal.utility.jdt.ShortCircuitAnnotationElementAdapter.setValue(ShortCircuitAnnotationElementAdapter.java:54)
	at org.eclipse.jpt.core.internal.resource.java.AbstractRelationshipMappingAnnotation.setCascadeTypes(AbstractRelationshipMappingAnnotation.java:229)
	at org.eclipse.jpt.core.internal.resource.java.AbstractRelationshipMappingAnnotation.setCascade(AbstractRelationshipMappingAnnotation.java:246)
	at org.eclipse.jpt.core.internal.resource.java.AbstractRelationshipMappingAnnotation.setCascadeAll(AbstractRelationshipMappingAnnotation.java:167)
	at org.eclipse.jpt.core.internal.context.java.JavaCascade.setAll(JavaCascade.java:43)
	at org.eclipse.jpt.ui.internal.mappings.details.CascadeComposite$1.setValue_(CascadeComposite.java:83)
	at org.eclipse.jpt.ui.internal.mappings.details.CascadeComposite$1.setValue_(CascadeComposite.java:1)
	at org.eclipse.jpt.utility.internal.model.value.PropertyAspectAdapter.setValue(PropertyAspectAdapter.java:152)
	at org.eclipse.jpt.ui.internal.swt.BooleanButtonModelAdapter.buttonSelected(BooleanButtonModelAdapter.java:195)
	at org.eclipse.jpt.ui.internal.swt.BooleanButtonModelAdapter$2.widgetSelected(BooleanButtonModelAdapter.java:140)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3823)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3422)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
	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:382)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1212)



A similar exception also occurs if you change the sequence of modifications and you first check one of the toggles for the CascadeType and after that you try to set the FetchType to a non-default value. Always the second modification is not replcted in the Java source file and leed to an exception added to the error log.
Comment 1 Reto Urfer CLA 2008-07-20 06:01:27 EDT
The same prolem can also be reproduced with setting the optional flag to a non-default value and either setting the FetchType or CascadeType. It seems that as soon as one annotation attribute has been set no second attribute can be set anymore in the same annotation.
Comment 2 Karen Butzke CLA 2008-07-20 10:10:10 EDT
With a simple use case I am not able to reproduce this.  Could you attach an entire file that shows this issue?  It seems like a strange one, and not one others have reported.
Comment 3 Reto Urfer CLA 2008-07-20 10:24:00 EDT
Created attachment 107885 [details]
Project I could reproduce the problem with

as javax.persistence provider I used ejb3-persistence.jar from Hibernate Annotations 3.3
Comment 4 Karen Butzke CLA 2008-07-21 10:23:03 EDT
Hi, could you try opening this project in a new clean workspace?  I am still unable to reproduce this problem.  It really appears that it is a JDT bug(since the exception occurs in JDT code) and maybe there is some preference you have set that is causing the problem.
Comment 5 Reto Urfer CLA 2008-07-21 13:00:32 EDT
You were right. With a new workspace everything works fine.

I also found the problem and could fix all my other workspaces. It was a code formatting template i once created with Eclipse 3.3. As soon as i activated it, the exceptions apeared. After i have recreated this formatter based on an Eclipse 3.4 built-in formatter i had no problems anymore.

This also solved the problems i reported with Bug# 241472!!!

Thanks for help
Comment 6 Karen Butzke CLA 2008-07-21 13:23:18 EDT
Glad to hear you fixed the problem, closing this bug
Comment 7 Reto Urfer CLA 2008-08-18 09:27:22 EDT
I run again into the same problem. 

It happens, if in a Java formatter definition on the 'New Llines' tab in the section 'Insert new line' the toggle 'in empty class body' is NOT checked. 

As soon as i check this button, everything is working fine. All the other check buttons do not seem to have any influence on the behaviour of the JPA Details view.
Comment 8 Karen Butzke CLA 2008-08-18 13:37:23 EDT
Reassigning to JDT, will attach a test project that shows the problem.
If you are inserting annotation values in source, setting the JDT preference FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION to false causes the annotation value pair not to be inserted.

In my test project I start with a field with the annotation @Basic(fetch=FetchType.EAGER).  I am trying to add the member value pair optional=true.  The exception shown in comment #1 is hit and the member value pair is not added.  
Comment 9 Karen Butzke CLA 2008-08-18 13:38:40 EDT
Created attachment 110265 [details]
test project - one failing test
Comment 10 Olivier Thomann CLA 2008-08-18 14:21:46 EDT
Reproduced.
I'll investigate.
Comment 11 Olivier Thomann CLA 2008-08-20 10:00:23 EDT
David,

The bug might actually come from the code formatter that returns too many edits.
Comment 12 David Audel CLA 2008-09-03 09:07:04 EDT

*** This bug has been marked as a duplicate of bug 234583 ***
Comment 13 Jerome Lanneluc CLA 2008-09-15 12:47:48 EDT
Verified for 3.5M2 using I20080914-2000 and test project from comment 9