Code generation injects method $$$setupUI$$$ in wrong place in constructor
--------------------------------------------------------------------------
Key: MOJO-1667
URL: http://jira.codehaus.org/browse/MOJO-1667
Project: Mojo
Issue Type: Bug
Components: ideauidesigner
Reporter: Sergey Ushakov
Attachments: uidesignerbug.tar.bz2
When plugin compiles form it injects call to method $$$setupUI$$$ to wrong
place and splits first instruction in constructor in parts.
Source code for form:
{code}
public class Form {
private JLabel label;
Object object;
public Form() {
object.toString();
}
public static void main(String[] args) {
try {
new Form();
System.err.println("Test passed");
} catch (NullPointerException e) {
System.err.println("Test failed");
System.exit(1);
}
}
private void createUIComponents() {
object = new Object();
label = new JLabel();
}
}
{code}
In this code, field "object" gets initialized in createUIComponents(), that is
known to be executed in $$$setupUI$$$.
Part of decompiled class-file, obtained from {monospace}javap -private -s -c
Form{monospace}
{quote}
Compiled from "Form.java"
public class uidesignerbug.Form extends java.lang.Object{
private javax.swing.JLabel label;
Signature: Ljavax/swing/JLabel;
java.lang.Object object;
Signature: Ljava/lang/Object;
public uidesignerbug.Form();
Signature: ()V
Code:
0: aload_0
1: invokespecial #13; //Method java/lang/Object."<init>":()V
4: aload_0
5: getfield #15; //Field object:Ljava/lang/Object;
8: aload_0
9: invokespecial #18; //Method $$$setupUI$$$:()V
12: invokevirtual #22; //Method
java/lang/Object.toString:()Ljava/lang/String;
15: pop
16: return
{quote}
Note, code line 9 with call to $$$setupUI$$$ is located in wrong place. It
should occur before line 4, pushing reference to uninitialized field.
IDEA version 10.* and 9.* also affected with bug. Related bug at JetBrains
issue tracker: http://youtrack.jetbrains.net/issue/IDEA-67765
Maven project with test and decompilation result attached.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email