What am I getting wrong with this "late" annotation? (InitializationError)

20 views
Skip to first unread message

Colin Bartolome

unread,
Sep 11, 2016, 11:33:14 AM9/11/16
to ceylon-users
I boiled down a situation I was seeing into this:

late String test;

"Run the module `lateTest`."
shared
void run() {
    test
= "test";
   
   
print(test);
}

When I run this module, I get this error:

Exception in thread "main" ceylon.language.InitializationError "Accessing uninitialized 'late' attribute 'test'"
    at lateTest.test_.get_(run.ceylon:1)
    at lateTest.run_.run(run.ceylon:7)
    at lateTest.run_.main(run.ceylon)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at ceylon.modules.api.runtime.SecurityActions.invokeRunInternal(SecurityActions.java:57)
    at ceylon.modules.api.runtime.SecurityActions.invokeRun(SecurityActions.java:48)
    at ceylon.modules.api.runtime.AbstractRuntime.invokeRun(AbstractRuntime.java:68)
    at ceylon.modules.api.runtime.AbstractRuntime.execute(AbstractRuntime.java:105)
    at ceylon.modules.api.runtime.AbstractRuntime.execute(AbstractRuntime.java:101)
    at ceylon.modules.Main.execute(Main.java:69)
    at ceylon.modules.Main.main(Main.java:42)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.jboss.modules.Module.run(Module.java:308)
    at org.jboss.modules.Main.main(Main.java:487)
    at ceylon.modules.bootstrap.CeylonRunTool.run(CeylonRunTool.java:281)
    at com.redhat.ceylon.common.tools.CeylonTool.run(CeylonTool.java:520)
    at com.redhat.ceylon.common.tools.CeylonTool.execute(CeylonTool.java:405)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.redhat.ceylon.launcher.Launcher.runInJava7Checked(Launcher.java:115)
    at com.redhat.ceylon.launcher.Launcher.run(Launcher.java:41)
    at com.redhat.ceylon.launcher.Launcher.run(Launcher.java:34)
    at com.redhat.ceylon.launcher.Launcher.main(Launcher.java:27)

What am I getting wrong in how I'm using the "late" annotation? This is with version 1.2.2 on Java 8.

Colin Bartolome

unread,
Sep 11, 2016, 11:34:37 AM9/11/16
to ceylon-users
Reply all
Reply to author
Forward
0 new messages