简体   繁体   中英

Importing java.lang in Ceylon

I have a simple import from java.lang at the top of my file:

import java.lang {UnsupportedOperationException}

As expected, I get this error:

Package not found in imported modules: 
java.lang (add module import to module descriptor of hello)

However, I have tried adding each the following to the body of module.ceylon no avail:

import java.lang; // needs a version
import java.lang "7"; // not found
import java.lang "1.7.0"; // still not found

If you are using the Ceylon IDE for Eclipse you can hover over the original import error and see the following suggestion:

1 quick fix avialable:
    Add 'import java.base' to module descriptor

Clicking that link will make your module.ceylon look like this:

module mymodule "1.0.0" {
  import java.base "7";
}

And everything will work. I am sure someone more helpful will come along and explain why java.lang is in java.base . For now, just accept that it is.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM