我正在尝试将从 ceylon.interop.java { CeylonList } 派生的锡兰类置于包含此派生的锡兰模块之外的 java 单元(在锡兰术语中,这将被称为模块,但 java 还没有)锡兰级。
运行锡兰:
import java.util {
JList=List
}
import ceylon.interop.java {
CeylonList
}
// CL is deliberately annotated as 'shared' - this is the crucial point !!
shared class CL(JList<out Integer> jil) extends CeylonList<Integer>(jil) {}
为了使导入的模块在 java 端可见,我将模块描述符中的导入模块注释为“共享”。
模块.锡兰:
native ("jvm") module com.example.simple "1.0.0" {
shared import "java.base" "8";
shared import ceylon.collection "1.2.2";
shared import ceylon.interop.java "1.2.2";
}
但是编译器还是报错:
source/com/example/simple/run.ceylon:18: error: supertype of type 'CL' that is visible outside this module comes from an imported module that is not re-exported: 'Collection<Integer>' involves an unexported type declaration
shared class CL(JList<out Integer> jil) extends CeylonList<Integer>(jil) {}
^
source/com/example/simple/run.ceylon:18: error: supertype of type 'CL' that is visible outside this module comes from an imported module that is not re-exported: 'List<Integer>' involves an unexported type declaration
shared class CL(JList<out Integer> jil) extends CeylonList<Integer>(jil) {}
^
source/com/example/simple/run.ceylon:18: error: supertype of type 'CL' that is visible outside this module comes from an imported module that is not re-exported: 'Correspondence<Integer,Integer>' involves an unexported type declaration
shared class CL(JList<out Integer> jil) extends CeylonList<Integer>(jil) {}
^
source/com/example/simple/run.ceylon:18: error: supertype of type 'CL' that is visible outside this module comes from an imported module that is not re-exported: 'Ranged<Integer,Integer,List<Integer>>' involves an unexported type declaration
shared class CL(JList<out Integer> jil) extends CeylonList<Integer>(jil) {}
解决方案应该是重新导出 ceylon.language
...
shared import ceylon.language "1.2.2";
...
但一方面 ceylon.language 根本不允许导入,因此不能对其进行注释,也不能重新导出。
另一方面,我找不到任何“...未重新导出的导入模块...”,因为所有导入的模块都被注释为共享。
旁白:然后从 run.ceylon 导入类 CL 并在 Use.java 中使用
使用.java:
package some.other.package
// And thus some.other.module if there were
import com.example.simple.*;
import java.util.* ;
public class Use{
public static void main (String[] args) {
LinkedList ll = new LinkedList();
ll.add(1);
ll.add(2);
CL c = new CL(ll);
}
}
现在的问题是(参考上面的错误消息),1. 什么超类型 'CL' 在这个模块之外是可见的并且来自一个没有重新导出的导入模块,以及 2. 如何重新导出它?