小编Luk*_*asz的帖子

思考 - Java 8 - 无效的常量类型

我有一个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抱歉英语:)

java javassist java-8 reflections

22
推荐指数
3
解决办法
4万
查看次数

附加文本WebEngine - JavaFX

如何将文本附加到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

text dom javafx append document-body

4
推荐指数
2
解决办法
6814
查看次数

标签 统计

append ×1

document-body ×1

dom ×1

java ×1

java-8 ×1

javafx ×1

javassist ×1

reflections ×1

text ×1