Closed Bug 1133717 Opened 9 years ago Closed 5 years ago

Dying in NativeJavaPackage contructor

Categories

(Rhino Graveyard :: Core, defect)

head
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INACTIVE

People

(Reporter: mjkim0324, Unassigned)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.93 Safari/537.36

Steps to reproduce:

<Test Case>
public void test(){
  NativeJavaPackage pack = new NativeJavaPackage("package");
}


Actual results:

NullPointerException in the constructor when currentContext is not available. 
public NativeJavaPackage(String packageName) {
  this(false, packageName,        Context.getCurrentContext().getApplicationClassLoader());
} 


Expected results:

I think there should be a null-checker for Context.getCurrentContext() in the constructor like  getContext() method in Context.java throws an exception in the same situation. 
    static Context getContext()
    {
        Context cx = getCurrentContext();
        if (cx == null) {
            throw new RuntimeException(
                "No Context associated with current Thread");
        }
        return cx;
    }

Closing. Bug management is now done here:
https://github.com/mozilla/rhino

Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Resolution: --- → INACTIVE
You need to log in before you can comment on or make changes to this bug.