Cannot access CPCallbackClassLoaderIf / XMLable (class file not found, when using Java 8)

121 views Asked by At

I've a strange problem, I cannot compile following code (with Java 8, with Java 6 I've no problems!).
I got following compile-time errors:

Compile Error 1:

error: cannot access CPCallbackClassLoaderIf com.sun.javaws.jnl.JARDesc[] descs = jnlpcl.getLaunchDesc().getResources().getEagerOrAllJarDescs(true); class file for com.sun.deploy.security.CPCallbackClassLoaderIf not found

and

Compile Error 2:

error: cannot access XMLable com.sun.javaws.jnl.JARDesc[] descs = jnlpcl.getLaunchDesc().getResources().getEagerOrAllJarDescs(true); class file for com.sun.deploy.xml.XMLable not found

NetBeans IDE shows no errors in this code!.

public static List<String> test() {
    try {
        List<String> ret = new ArrayList<String>();
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        if (cl instanceof com.sun.jnlp.JNLPClassLoader) {
            com.sun.jnlp.JNLPClassLoader jnlpcl = (com.sun.jnlp.JNLPClassLoader)cl;
            /*COMPILE ERROR1*/ com.sun.javaws.jnl.JARDesc[] descs = jnlpcl.getLaunchDesc().getResources().getEagerOrAllJarDescs(true);
            for (com.sun.javaws.jnl.JARDesc d : descs)
            {
            /*COMPILE ERROR2*/ JarFile jf = jnlpcl.getJarFile(d.getLocation());
                ret.add(new File(jf.getName()).getAbsolutePath());
            }
        }
        return ret;
    } catch (Exception ex) {
        //ignore
    }
    return null;
}

I checked deploy.jar and indeed, this class does not exists anymore in Java 8 (but in Java 6).

Why does this error happens and how can I get rid of this error, when using this code and Java 8?

0

There are 0 answers