Dying in NativeJavaPackage contructor

UNCONFIRMED
Unassigned

Status

Rhino
Core
UNCONFIRMED
3 years ago
3 years ago

People

(Reporter: Kim, Unassigned)

Tracking

Details

(Reporter)

Description

3 years ago
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;
    }
You need to log in before you can comment on or make changes to this bug.