How to recompile JavaFX 11/12

孤街浪徒 提交于 2019-12-11 18:31:42

问题


I'm trying to recompile JavaFX 11 (or 12) from source in an eclipse project, but I encounter some problems.

Here is how I proceed:
1. I download the JavaFX SDK for Windows here
2. I create an eclipse project for each JavaFX module (javafx.base, javafx.controls, javafx.fxml, javafx.graphics, javafx.media, javafx.swing and javafx.web)
3. I correct various minor compilation errors
4. Finally I create a simple JavaFX application in a new project

But when I execute the application, I get this error:

java.lang.ClassNotFoundException: com.sun.prism.shader.Texture_Color_Loader
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:315)
    at javafx.graphics/com.sun.prism.d3d.D3DResourceFactory.createStockShader(D3DResourceFactory.java:405)
    at javafx.graphics/com.sun.prism.impl.ps.BaseShaderContext.getPaintShader(BaseShaderContext.java:263)
    at javafx.graphics/com.sun.prism.impl.ps.BaseShaderContext.validatePaintOp(BaseShaderContext.java:484)
    at javafx.graphics/com.sun.prism.impl.ps.BaseShaderContext.validatePaintOp(BaseShaderContext.java:414)
    at javafx.graphics/com.sun.prism.impl.ps.BaseShaderGraphics.drawString(BaseShaderGraphics.java:2089)
    at javafx.graphics/com.sun.javafx.sg.prism.NGText.renderText(NGText.java:312)
    at javafx.graphics/com.sun.javafx.sg.prism.NGText.renderContent2D(NGText.java:270)
    at javafx.graphics/com.sun.javafx.sg.prism.NGShape.renderContent(NGShape.java:261)
    at javafx.graphics/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
    at javafx.graphics/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
    at javafx.graphics/com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
    at javafx.graphics/com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
    at javafx.graphics/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
    at javafx.graphics/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
    at javafx.graphics/com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
    at javafx.graphics/com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
    at javafx.graphics/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
    at javafx.graphics/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
    at javafx.graphics/com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:479)
    at javafx.graphics/com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:328)
    at javafx.graphics/com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:91)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
    at javafx.graphics/com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
    at java.base/java.lang.Thread.run(Thread.java:834)
java.lang.InternalError: Error loading stock shader Texture_Color
    at javafx.graphics/com.sun.prism.d3d.D3DResourceFactory.createStockShader(D3DResourceFactory.java:411)
    at javafx.graphics/com.sun.prism.impl.ps.BaseShaderContext.getPaintShader(BaseShaderContext.java:263)
    at javafx.graphics/com.sun.prism.impl.ps.BaseShaderContext.validatePaintOp(BaseShaderContext.java:484)
    at javafx.graphics/com.sun.prism.impl.ps.BaseShaderContext.validatePaintOp(BaseShaderContext.java:414)
    at javafx.graphics/com.sun.prism.impl.ps.BaseShaderGraphics.drawString(BaseShaderGraphics.java:2089)
    at javafx.graphics/com.sun.javafx.sg.prism.NGText.renderText(NGText.java:312)
    at javafx.graphics/com.sun.javafx.sg.prism.NGText.renderContent2D(NGText.java:270)
    at javafx.graphics/com.sun.javafx.sg.prism.NGShape.renderContent(NGShape.java:261)
    at javafx.graphics/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
    at javafx.graphics/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
    at javafx.graphics/com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
    at javafx.graphics/com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
    at javafx.graphics/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
    at javafx.graphics/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
    at javafx.graphics/com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270)
    at javafx.graphics/com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578)
    at javafx.graphics/com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072)
    at javafx.graphics/com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964)
    at javafx.graphics/com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:479)
    at javafx.graphics/com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:328)
    at javafx.graphics/com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:91)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
    at javafx.graphics/com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at javafx.graphics/com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:125)
    at java.base/java.lang.Thread.run(Thread.java:834)

When I look in the class where the exception is thrown, there is this chunk of code:


    public Shader createStockShader(final String name) {
        if (name == null) {
            throw new IllegalArgumentException("Shader name must be non-null");
        }
        try {
            InputStream stream = AccessController.doPrivileged(
                    (PrivilegedAction) () -> D3DResourceFactory.class.
                           getResourceAsStream("hlsl/" + name + ".obj")
            );
            Class klass = Class.forName("com.sun.prism.shader." + name + "_Loader");
            Method m = klass.getMethod("loadShader",
                new Class[] { ShaderFactory.class, InputStream.class });
            return (Shader)m.invoke(null, new Object[] { this, stream });
        } catch (Throwable e) {
            e.printStackTrace();
            throw new InternalError("Error loading stock shader " + name);
        }
    }

It is trying to load classes from the package com.sun.prism.shader and ressources from the package com.sun.prism.d3d.hlsl, but these packages do not exist in the sources folders. I looked in the pre-compiled jar javafx.graphics.jar if these files exists, and there are here.

So, what should I do to make it works? I tried to create the missing package and extract .class files into it, but eclipse automatically delete them because there is no .java files associated i guess.

And, I don't understand why is it missing ressources files in sources archive file? The goal of giving access to sources is not to recompile and work/modify them easily?

On the github where I get the sources, they give a link with all instructions for building OpenJFX, but the site seems to be under maintenance for ages now...

来源:https://stackoverflow.com/questions/55704337/how-to-recompile-javafx-11-12

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!