Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot load file with more than one "complex" CustomElement #517

Closed
cdir opened this issue Oct 1, 2018 · 1 comment
Closed

Cannot load file with more than one "complex" CustomElement #517

cdir opened this issue Oct 1, 2018 · 1 comment
Labels
Milestone

Comments

@cdir
Copy link

cdir commented Oct 1, 2018

I found out that the Umlet CustomElement is very powerful and you can draw realy complex diagram with very few imput. So I wrote some code and found out that it is even possible to have inner classes inside this single method, that means I have created some model classes as method-internal classes.

Unfortunately there seems to be a bug in classloading when I have more than one such diagram in one uxf-file. In the ZIP there are two very simple Umlet diagram, I just used the default custom element template and added one internal class. In the first there is only one element of this kind and it opens easily in umlet. The second one just has two element of the same kind and I get NoClassDefFoundError: CustomElementImpl$1Test (Test is the name of the inner class).

InnerClassUmlet.zip

Within an open file there is no problem by adding more elements (just copy/pase). The problem only occures on file open. I assume any timing/threading problem.

This is the stacktrace.

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: CustomElementImpl$1Test
	at CustomElementImpl.paint(CustomElementImpl.java:34)
	at com.baselet.element.old.custom.CustomElement.paintEntity(CustomElement.java:190)
	at com.baselet.element.old.OldGridElement.paint(OldGridElement.java:394)
	at java.awt.Component.lightweightPaint(Component.java:3283)
	at java.awt.Container.lightweightPaint(Container.java:2058)
	at java.awt.GraphicsCallback$PeerPaintCallback.run(GraphicsCallback.java:85)
	at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:79)
	at java.awt.Component.paintAll(Component.java:3269)
	at java.awt.GraphicsCallback$PaintAllCallback.run(GraphicsCallback.java:61)
	at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:79)
	at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:109)
	at java.awt.Container.paintComponents(Container.java:2046)
	at com.baselet.diagram.DrawPanel.paintChildren(DrawPanel.java:486)
	at javax.swing.JComponent.paint(JComponent.java:1065)
	at javax.swing.JLayeredPane.paint(JLayeredPane.java:586)
	at javax.swing.JComponent.paintChildren(JComponent.java:889)
	at javax.swing.JComponent.paint(JComponent.java:1065)
	at javax.swing.JViewport.paint(JViewport.java:728)
	at javax.swing.JComponent.paintChildren(JComponent.java:889)
	at javax.swing.JComponent.paint(JComponent.java:1065)
	at javax.swing.JComponent.paintToOffscreen(JComponent.java:5210)
	at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1579)
	at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1502)
	at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:306)
	at javax.swing.RepaintManager.paint(RepaintManager.java:1272)
	at javax.swing.JComponent._paintImmediately(JComponent.java:5158)
	at javax.swing.JComponent.paintImmediately(JComponent.java:4969)
	at javax.swing.RepaintManager$4.run(RepaintManager.java:831)
	at javax.swing.RepaintManager$4.run(RepaintManager.java:814)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
	at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:814)
	at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:789)
	at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:738)
	at javax.swing.RepaintManager.access$1200(RepaintManager.java:64)
	at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1732)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

edit: The same problem occures when I have two files with only one element of this kind and try to open both files at once (multi-select in open dialog).

@afdia
Copy link
Collaborator

afdia commented Oct 3, 2018

Thanks for the report, it seems like you are the first person to try out inner classes in custom elements ;)

The problem was that the compiled inner class file was deleted too soon. After changing it to deleteOnExit it works.

for documentation, this is the uxf file which I have used to check if it works after the fix:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<diagram program="umlet" version="14.4.0-SNAPSHOT">
  <zoom_level>10</zoom_level>
  <element>
    <type>CustomElementImpl</type>
    <coordinates>
      <x>160</x>
      <y>240</y>
      <w>201</w>
      <h>201</h>
    </coordinates>
    <panel_attributes>// Modify the text below and
// observe the element preview.

Hello, World! 
Enjoy UMLet!</panel_attributes>
    <additional_attributes/>
    <custom_code>//Modify the code below to define the element's behavior.
//
//Example:  Change the line
//  y += printCenter(textline,y);
//to
//  y += 2*printCenter(textline,y);
//and observe the element preview.

class Test {
	int yy=textHeight();
}
int y = new Test().yy;
drawRectangle(0,0,width,height);

for(String textline : textlines) {
	y += printCenter(textline,y);
}</custom_code>
  </element>
  <element>
    <type>CustomElementImpl</type>
    <coordinates>
      <x>30</x>
      <y>30</y>
      <w>201</w>
      <h>201</h>
    </coordinates>
    <panel_attributes>// Modify the text below and
// observe the element preview.

Hello, World! 
Enjoy UMLet!</panel_attributes>
    <additional_attributes/>
    <custom_code>//Modify the code below to define the element's behavior.
//
//Example:  Change the line
//  y += printCenter(textline,y);
//to
//  y += 2*printCenter(textline,y);
//and observe the element preview.

class Test {
	int yy=textHeight();
}
int y = new Test().yy;
drawRectangle(0,0,width,height);

for(String textline : textlines) {
	y += printCenter(textline,y);
}</custom_code>
  </element>
</diagram>

@afdia afdia closed this as completed Oct 3, 2018
@afdia afdia added this to the Umlet 14.4 milestone Oct 3, 2018
@afdia afdia added the bug label Oct 3, 2018
ddetleffsen pushed a commit to ddetleffsen/umlet that referenced this issue Nov 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants