Open jvasileff opened 8 years ago
As observed in https://github.com/ceylon/ceylon-compiler/issues/2371, forward-reference checks can be circumvented. Issues with statement ordering with respect to declarations may exist as well.
This example produces surprising results where an immutable value seemingly changes, due to first being used in an uninitialized state:
shared native class C() { shared native Integer a = 1; shared native Integer b = 2; shared void printA() => print("a=``a``"); shared void printB() => print("b=``b``"); } shared native("jvm") class C() { shared native("jvm") Integer a = -b; printB(); } shared void run() { value c = C(); // b=0 c.printB(); // b=2 c.printA(); // a=0 }
Similarly, a NullPointerException can occur:
NullPointerException
shared native class C() { shared native Integer a = -1; shared native String b = "b"; } shared native("jvm") class C() { shared native("jvm") Integer a = b.size; //java.lang.NullPointerException // at ceylon.language.String.getSize(String.java:242) }
ps - I realize this is not for 1.2.
Thanks for opening an issue for this one so we won't forget it @jvasileff .
More discussion is still available in the original issue.
As observed in https://github.com/ceylon/ceylon-compiler/issues/2371, forward-reference checks can be circumvented. Issues with statement ordering with respect to declarations may exist as well.
This example produces surprising results where an immutable value seemingly changes, due to first being used in an uninitialized state:
Similarly, a
NullPointerException
can occur:ps - I realize this is not for 1.2.