Menu

#47 String concat operation throws NullPointerException

closed-fixed
5
2004-06-29
2004-03-10
Anonymous
No

Version of Janino: 1.0.22

What I did:
bash$ cat TestA.java TestB.java
public class TestA {
static String something;
public static void main(String[] args) throws Exception {
something += 'a';
System.out.println(something);
}
}

public class TestB {
static String something;
public static void main(String[] args) throws Exception {
System.out.println(something + 'a');
}
}

What I expected to happen:
bash$ javac TestA.java TestB.java
bash$ java TestA
nulla
bash$ java TestB
nulla

What actually happened:
bash$ janino TestA
java.lang.reflect.InvocationTargetException
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:324)
at net.janino.JavaSourceClassLoader.main(Unknown Source)
Caused by: java.lang.NullPointerException
at TestA.main(.\TestA.java:4)
... 5 more
bash$ janino TestB
java.lang.reflect.InvocationTargetException
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:324)
at net.janino.JavaSourceClassLoader.main(Unknown Source)
Caused by: java.lang.NullPointerException
at TestB.main(.\TestB.java:4)
... 5 more

Discussion

  • Arno Unkrig

    Arno Unkrig - 2004-06-26

    Logged In: YES
    user_id=865893

    For some reason I was not notified about this bug and so I
    missed it. I'll probably fix it next week.

     
  • Arno Unkrig

    Arno Unkrig - 2004-06-29

    Logged In: YES
    user_id=865893

    Bug fixed in "string conversion": Convert NULL reference to
    n-u-l-l also when the source type is "String".

    Will be released with version 2.0.4.

    By the way, Mr. anonymous -- who are you?
    Thank you for the precise bug report!

     
  • Arno Unkrig

    Arno Unkrig - 2004-06-29
    • status: open --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB