我有一个Reflections库的问题.我试图动态加载实现特定接口的所有类.只要我不在这些类中使用lambda表达式(java 8),一切正常(所有类都已加载).我尝试升级lib版本,但效果是相同的(java.io.IOException:无效的常量类型:18).
依赖并在pom.xml中构建
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.10</version>
<exclusions>
<exclusion>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.19.0-GA</version>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
不排斥是同样的效果.
码:
URL jarUrl = jarFile.toURI().toURL();
URLClassLoader child = new URLClassLoader(new URL[]{jarUrl}, this.getClass().getClassLoader());
ConfigurationBuilder builder = new ConfigurationBuilder()
.addClassLoader(child)
.addUrls(jarUrl)
.setScanners(new SubTypesScanner());
Reflections r = new Reflections(builder);
return r.getSubTypesOf(cls);
Run Code Online (Sandbox Code Playgroud)
如何使用lambda表达式加载类?
PS抱歉英语:)
如何将文本附加到webengine?我试过这个:
public TabMessage(String title) {
super(title);
view = new WebView();
engine = view.getEngine();
engine.loadContent("<body></body>");
view.setPrefHeight(240);
}
private void append(String msg){
Document doc = engine.getDocument();
Element el = doc.getElementById("body");
String s = el.getTextContent();
el.setTextContent(s+msg);
}
Run Code Online (Sandbox Code Playgroud)
但文件是 null