Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6145939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:52:10+00:00 2026-05-23T18:52:10+00:00

In the sun.org.mozilla version of Rhino, JavaAdapter only takes interfaces as its first argument

  • 0

In the sun.org.mozilla version of Rhino, JavaAdapter only takes interfaces as its first argument instead of any other kind of class according to this error message:

javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorExcep
tion: JavaAdapter: first arg should be interface Class (<Unknown source>#11) in
<Unknown source> at line number 11

Is there any way, no matter how hacky, to extend an abstract class (or a normal class for that matter) via Rhino?

Here is the offending code:

var j = new JavaAdapter(foo.bar.abstractClass, {
    field : "test",
    method : function () {
        print("on enable");
    }
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:52:11+00:00Added an answer on May 23, 2026 at 6:52 pm

    The other answer is correct for the Sun version of Rhino. It’s not entirely clear from the phrasing of the question if switching to the original (Mozilla) Rhino is an option for you or not.

    Specifically, when Sun added Rhino to Java, “a few components have been excluded due to footprint and security reasons“, and one of them was Mozilla’s JavaAdapter. Sun wrote their own “JavaAdapter” but it is much smaller and simpler than the Mozilla one, and it can only be used to implement a single Java interface. Mozilla’s original JavaAdapter has no such restriction: I use it to implement abstract classes all the time.

    It has nothing to do with some vague philosophical difference like “JavaScript isn’t actually ‘OO’ in the same way as Java”. Sun thought that “The uses of JavaAdapter to extend a Java class or to implement multiple interfaces are very rare” (ibid) and decided to remove this feature.

    If it’s acceptable to ship an 850KB jar file with your code, then grab Mozilla Rhino and implement all the abstract classes you want!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My web.xml is like <web-app version=2.4 xmlns=http://java.sun.com/xml/ns/j2ee xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd> <display-name>sample</display-name> <servlet> <servlet-name>Sampleclass</servlet-name> <servlet-class>sample.SampleClass</servlet-class>
May I know how to I create a name cleaning function for sun.org.mozilla.javascript? I
I came across this method in the JDK From com.sun.org.apache.xml.internal.serializer.Version; public static int getDevelopmentVersionNum()
I have been using com.sun.org.apache.xpath.internal.XPathAPI for some time and it seems to work ok.
I mean, can I use the com.sun.org.apache (all subpackages) classes as I use they
I have downloaded and compiled the newest version of Rhino by going ant compile
org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar
import com.sun.org.apache.xerces.internal.dom.DOMImplementationImpl; public static Document newDocument( String pName ) { return DOMImplementationImpl.getDOMImplementation().createDocument( null, pName,
private static RE _TaskTypeRE = new RE(~:~([0-9]*)~); and this requires import com.sun.org.apache.regexp.internal.RE; So on
My web.xml is: http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd id=WebApp_ID version=2.5> TestStruts2 <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.