JDK-8041916 : ScriptEngine.getInterface fails if interface has static methods
  • Type: Bug
  • Component: core-libs
  • Sub-Component: javax.script
  • Affected Version: 8
  • Priority: P3
  • Status: Resolved
  • Resolution: Duplicate
  • OS: windows_7
  • CPU: x86
  • Submitted: 2014-04-23
  • Updated: 2014-05-02
  • Resolved: 2014-05-02
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :


A DESCRIPTION OF THE PROBLEM :
See test script below. First getInterface call returns non-null; second returns null. The only difference is the additional static method. Since static methods are not overrideable, their presence should be of no consequence.

--------

import javax.script.*;

class Test {
	public static void main(String[] args) throws Throwable {
		ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
		engine.eval("var obj = { run: function() {} };");
		System.out.println(((Invocable)engine).getInterface(engine.get("obj"), A.class));
		System.out.println(((Invocable)engine).getInterface(engine.get("obj"), B.class));
	}
	
	public interface A {
		void run();
	}
	
	public interface B {
		void run();
		static void foo() {}
	}
}

--------

I know I've filed this bug under the wrong subcategory -- that's your own stupid fault because nothing encompassing javax.script is on the list. Deal with it. I know you won't, though -- I am beyond sick and tired of every bug I report being flagrantly ignored, but I'll keep trying anyway. Perhaps somewhere, someday, someone will at least read one of them.


REPRODUCIBILITY :
This bug can be reproduced always.


Comments
Duplicate of JDK-8031359
02-05-2014

Yes, this bug is reproduced with jdk 8 GA. But this is not reproduced with jdk9 and jdk8u-dev (jdk8u20) repos. I think the fix for JDK-8031359 fixed this issue as well. As part of JDK-8031359, check for abstract methods was included - rather than taking all interface methods including default methods - but the same check works for static methods as well (as static methods are not abstract). So, this issue is fixed in jdk9 as well as jdk8u-dev. I'm resolving current issue as 'duplicate' of JDK-8031359.
02-05-2014