How to enable Gluegen (Java3D) on Java 9

classic Classic list List threaded Threaded
26 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: How to enable Gluegen (Java3D) on Java 9

Predrag Bokšić
Hello Julien! How are you?

I think that I tested that option among many other options with negative success. I also recompiled the Java3D library for JDK 8 and alternatively, for JDK 9 with some small edits. It does not change anything on any platform, roughly speaking. It failed on OpenJDK... but I destroyed the OpenJDK and recompiled for Ubuntu 16 successfully with OracleJDK. I tried to set the default NOOP renderer, but it failed on all systems. I tried to combine things with the latest Jogamp auto build edition, but it does not change anything.

On MacOS, the execution looks like this:

java -jar project5-test.jar
3D [dev] @VERSION_BASE@-@VERSION_SUFFIX@-experimental @BUILDTIME_VERBOSE@

Initializing 3D runtime system:
    version = @VERSION_BASE@-@VERSION_SUFFIX@-experimental @BUILDTIME_VERBOSE@
    vendor = @IMPL_VENDOR@
    specification.version = 1.6
    specification.vendor = @SPEC_VENDOR@

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by javax.media.j3d.JoglPipeline (file:/Users/lyon/attachments/foo/foo/project5-test/project5-test.jar) to method sun.awt.AppContext.getAppContext()
WARNING: Please consider reporting this to the maintainers of javax.media.j3d.JoglPipeline
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
3D system initialized
    rendering pipeline = JOGL

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00000001349250cc, pid=4008, tid=775
#
# JRE version: Java(TM) SE Runtime Environment (9.0+11) (build 9.0.1+11)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (9.0.1+11, mixed mode, tiered, compressed oops, g1 gc, bsd-amd64)
# Problematic frame:
# C  [libosxapp.dylib+0x20cc]  -[NSApplicationAWT sendEvent:]+0x179


The code for testing looks like this:

import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.SimpleUniverse;

import javax.media.j3d.BranchGroup;
import javax.media.j3d.Canvas3D;
import javax.media.j3d.GraphicsConfigTemplate3D;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Enumeration;
import java.util.Properties;

/**
 * Sources
 * <p>
 * https://jogamp.org/deployment/jogamp-current/fat/
 * http://jogamp.org/deployment/java3d/1.6.0-final/
 **/

public class StillCube {
    /**
     * Run parameters
     * -Dj3d.allowNullGraphicsConfig --add-exports=java.base/java.lang=ALL-UNNAMED --add-exports=java.desktop/sun.awt=ALL-UNNAMED --add-exports=java.desktop/sun.java2d=ALL-UNNAMED
     * <p>
     * Problem
     * <p>
     * At least, Canvas3D(gc) turns rogue on some platforms or with some library versions possibly due to Gluegen library.
     * Jogl 2.3.2 has a bug concerning the Mesa drivers, which affects Ubuntu 17.
     * JDK 9 has a bug probably in AWT that affects MacOS.
     * <p>
     * <p>
     * What works well
     * <p>
     * Windows 10, Ubuntu 16, both with JDK 9, and JDK 8 on all platforms.
     */

    // this makes an error java.lang.IllegalArgumentException: Canvas3D: GraphicsConfiguration is not compatible with Canvas3D, but it works!?
    public static GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    public static GraphicsDevice gd = ge.getDefaultScreenDevice();
    public static GraphicsConfiguration gc = gd.getDefaultConfiguration();
    // Java3D vars
    public static Canvas3D c3d;
    public static SimpleUniverse su;

    static {
        try {
            gc = SimpleUniverse.getPreferredConfiguration(); // this works
            // Canvas3D default graphics configuration
            GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
            GraphicsConfiguration defaultGcfg = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(template);
            gc = defaultGcfg; // this works as well
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    static {
        try {
            // -Dj3d.allowNullGraphicsConfig property for Canvas3D
            c3d = new Canvas3D(gc);
        } catch (Exception e) {
            e.printStackTrace();
        }

        try {
            su = new SimpleUniverse(c3d);
            su.getViewingPlatform().setNominalViewingTransform();
            su.addBranchGraph(getBranchGroup());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    public StillCube() {
        try {
            Frame f = new Frame();
            f.setLayout(new BorderLayout());
            Panel p = new Panel(new BorderLayout());
            p.add(BorderLayout.CENTER, c3d);
            f.add(p, BorderLayout.CENTER);
            f.setSize(400, 400);
            f.setVisible(true);
            f.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent windowevent) {
                    f.dispose();
                    System.exit(0);
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    public static void main(String args[]) {
        System.setProperty("sun.java2d.noddraw", "false"); // should NOT be TRUE!
        System.setProperty("sun.awt.noerasebackground", "true"); // necessary
        //System.setProperty("sun.java2d.opengl", "True"); // no effect
//        System.setProperty("sun.java2d.opengl", "false"); // no effect
//        System.setProperty("sun.java2d.d3d", "false"); // no effect
//        System.setProperty("sun.java2d.d3dtexbpp", "16"); // no effect
//        System.setProperty("sun.java2d.ddoffscreen", "false"); // no effect
//        System.setProperty("sun.java2d.pmoffscreen", "false"); // no effect
//        System.setProperty("sun.java2d.ddforcevram", "false"); // no effect
//        System.setProperty("sun.java2d.accthreshold", "0"); // no effect
//        System.setProperty("sun.java2d.translaccel", "true"); // no effect
//        System.setProperty("sun.java2d.xrender", "True"); // no effect
//        System.setProperty("sun.java2d.opengl.fbobject", "false"); // no effect
        System.setProperty("newt.debug", "all");
        System.setProperty("nativewindow.debug", "all");
        System.setProperty("jogl.debug", "all");


//        final String rendStr = getProperty("j3d.rend");
//        System.out.println("J3D renderer is: " + rendStr);


        final StillCube stillCube = new StillCube();

        //final OneTriangleAWT oneTriangleAWT = new OneTriangleAWT();
        //oneTriangleAWT.main(null);

        //getSystemProperties();


    }


    public static String getProperty(final String prop) {
        return java.security.AccessController.doPrivileged(
                (PrivilegedAction<String>) () -> System.getProperty(prop));
    }


    public static void getSystemProperties() {
        AccessController.doPrivileged(
                (PrivilegedAction) () -> {
                    Properties p = System.getProperties();
                    Enumeration keys = p.keys();
                    while (keys.hasMoreElements()) {
                        String key = (String) keys.nextElement();
                        String value = (String) p.get(key);
                        System.out.println(key + " : " + value);
                    }
                    return null;
                });
    }


    public static BranchGroup getBranchGroup() {
        BranchGroup bg = new BranchGroup();
        try {
            bg.addChild(new ColorCube(.3));
            bg.compile();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return bg;
    }
}


Maybe it is time to visit the # Problematic frame:
# C  [libosxapp.dylib+0x20cc]  -[NSApplicationAWT sendEvent:]+0x179 ?
Reply | Threaded
Open this post in threaded view
|

Re: How to enable Gluegen (Java3D) on Java 9

gouessej
Administrator
Hi

I succeed in compiling Java3D 1.6 and 1.7 with OpenJDK 1.8 under Mageia Linux. Actually, I have never compiled it with Oracle Java.

Phil might confirm, he plans to add some AWT free support into Java3D 1.7, it would help as we wouldn't have to load AWT.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: How to enable Gluegen (Java3D) on Java 9

Predrag Bokšić
I can see that I can compile jogl, glugen, j3d in Ubuntu 16 fast and easy. Do I also compile for MacOS by any chance? I have MacOS SDK in a folder, but I don't know where to specify it for the Ant build system.
Reply | Threaded
Open this post in threaded view
|

Re: How to enable Gluegen (Java3D) on Java 9

gouessej
Administrator
It should work. Why do you talk about Mac OS X SDK? You need XCode or at least GCC.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: How to enable Gluegen (Java3D) on Java 9

Predrag Bokšić
Julien, if I am wasting your time, please be free to interrupt me. Here, I have many different operating systems installed. The MacOS is inconvenient for work with because it is contained in the VirtualBox. (By contrast, VMware has much more amazing capabilities.) I've hoped that I could set up a "build environment" entirely on a single operating system in analogy with the automated build environment that you probably have. It would be nice to have the option to switch the operating systems and perform something like:
ant clean
ant build windows
ant clean
ant build macos sdkdir=~/macos_sdk/
...
The difference would be the include path.

I know that the command "ant build all" does not build all the native libraries. Windows and Linux natives are good, individually. Should I forget about all this now? :-)
Reply | Threaded
Open this post in threaded view
|

Re: How to enable Gluegen (Java3D) on Java 9

gouessej
Administrator
No, you're not, your help is precious and Sven asked me the bug list yesterday, something is going to happen.

There is no such environment because fully cross compiling all native libraries under GNU Linux would be very very difficult to do and the result might be less than optimal.
Julien Gouesse | Personal blog | Website
12