views:

22

answers:

1

In my java program I make heavy use of Suns implmentation of the Rhino script engine. Very recently however, my JDK does not seem to automatically import the rt.jar file anymore when compiling.

Whats strange is that NetBeans reports 0 live errors, they only show up when doing a complete Clean & Build. This wasn't happening before when I was importing NativeArray, so I'm really confused on why it all of a sudden stopped working.

Specs:

  • OS - Windows
  • Java version - java version "1.6.0_20"
  • Javac version - javac 1.6.0_20
  • NetBeans version - 6.9

Check to see if it exists:

C:\Documents and Settings\LordQuackstar\Desktop\TestApp\src>javap sun.org.mozill
a.javascript.internal.WrappedException
Compiled from "WrappedException.java"
public class sun.org.mozilla.javascript.internal.WrappedException extends sun.or
g.mozilla.javascript.internal.EvaluatorException{
    static final long serialVersionUID;
    public sun.org.mozilla.javascript.internal.WrappedException(java.lang.Throwa
ble);
    public java.lang.Throwable getWrappedException();
    public java.lang.Object unwrap();
}

Ok it exists, so here's some test code:

package testapp;

import sun.org.mozilla.javascript.internal.WrappedException;

public class Main {
    public static void main(String[] args) {
        WrappedException e = new WrappedException(null);
    }
}

Netbeans output:

init:
deps-clean:
Updating property file: C:\Documents and Settings\LordQuackstar\Desktop\TestApp\build\built-clean.properties
Deleting directory C:\Documents and Settings\LordQuackstar\Desktop\TestApp\build
clean:
init:
deps-jar:
Created dir: C:\Documents and Settings\LordQuackstar\Desktop\TestApp\build
Updating property file: C:\Documents and Settings\LordQuackstar\Desktop\TestApp\build\built-jar.properties
Created dir: C:\Documents and Settings\LordQuackstar\Desktop\TestApp\build\classes
Created dir: C:\Documents and Settings\LordQuackstar\Desktop\TestApp\build\empty
Compiling 1 source file to C:\Documents and Settings\LordQuackstar\Desktop\TestApp\build\classes
C:\Documents and Settings\LordQuackstar\Desktop\TestApp\src\testapp\Main.java:8: package sun.org.mozilla.javascript.internal does not exist
import sun.org.mozilla.javascript.internal.WrappedException;
C:\Documents and Settings\LordQuackstar\Desktop\TestApp\src\testapp\Main.java:16: cannot find symbol
symbol  : class WrappedException
location: class testapp.Main
                WrappedException e = new WrappedException(null);
                ^
C:\Documents and Settings\LordQuackstar\Desktop\TestApp\src\testapp\Main.java:16: cannot find symbol
symbol  : class WrappedException
location: class testapp.Main
                WrappedException e = new WrappedException(null);
                                         ^
3 errors
C:\Documents and Settings\LordQuackstar\Desktop\TestApp\nbproject\build-impl.xml:528: The following error occurred while executing this line:
C:\Documents and Settings\LordQuackstar\Desktop\TestApp\nbproject\build-impl.xml:261: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)

Command line output:

C:\Documents and Settings\LordQuackstar\Desktop\TestApp\src\testapp>javac Main.java
Main.java:3: package sun.org.mozilla.javascript.internal does not exist
import sun.org.mozilla.javascript.internal.WrappedException;
                                          ^
Main.java:7: cannot find symbol
symbol  : class WrappedException
location: class testapp.Main
        WrappedException e = new WrappedException(null);
        ^
Main.java:7: cannot find symbol
symbol  : class WrappedException
location: class testapp.Main
        WrappedException e = new WrappedException(null);
                                 ^
3 errors

So what would cause this to fail all of a sudden? It was working just fine yesterday. I didn't change anything besides importing 2 more classes from the same package. None of my dependencies changed.

Will test in linux to see if the problem still exists.

Before you say it: No I'm not download rhino separatly, No I'm not changing IDEs,

+4  A: 

There are two indications that you shouldn't use this class: sun and internal - these mean that this is some internal class that shouldn't be used by third parties. Because it can change or be removed in future releases - i.e. this is not part of an API. So - download Rhino separately.

If you are using the scripting API - use only the API classes/interfaces - i.e. javax.script

Bozho
Then how do you expect to be able to access javascript arrays from java without the ridiculous syntax of `java.lang.reflect.Array.newInstance(java.lang.String, 5);`? How would you get access to json objects? You can't. javax.script is nothing more than an abstraction layer. There is nothing stopping me from using Sun's namespace, and internal is just some weird sun management (There are no classes inbetween org.mozilla and org.mozilla.rhino.internal.)
TheLQ
if the abstraction is not enough, use the raw implementation directly - download rhino and use it.
Bozho
Suns implementation works just fine. I would prefer not to add yet another dependency to an already large list for a framework when a perfectly good one exists by default.
TheLQ