Closed Bug 547071 Opened 14 years ago Closed 5 years ago

Java hosted module script provider for CommonJS

Categories

(Rhino Graveyard :: Core, enhancement)

x86
Windows XP
enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED INACTIVE

People

(Reporter: jpalka, Unassigned)

Details

Attachments

(1 file, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9.2) Gecko/20100115 Firefox/3.6
Build Identifier: 

This is initial implementation of Java hosted module script provider for CommonJS together with test cases.
It uses annotations and package-info.java (more in test code).
At the moment it works, but I don't like the exceptions are handled.

Reproducible: Always
Attached patch 547071 (obsolete) — Splinter Review
First version of Java hosted module script provider for CommonJS.
Looks interesting! I'm not sure it's a good idea to limit the exported objects to classes/constructors. A module may want to export other things such as functions, strings, number constants. I think we need to give modules more control on how to set up the exports object (in addition to your list of classes/constructors).

On a coding style level, I think it would be preferable to throw/propagate exceptions instead of just printing stack traces.
I agree it'd be preferred to propagate the exceptions. 

I just updated the declaration of the ModuleScriptProvider.getModuleScript() method - it can now throw any Exception, not just IOException, so you should be able to just propagate those with no friction.
This is second attempt to Java hosted modules.

First I changed exception handling and now I throw exceptions (thanks Attila for changes in ModuleScriptProvider interface). However I do hide ClassNotFoundException as it is handled by Require.getModule and I don't think it is good idea to handle module not found in other places.

I have also added support for exporting other things than classes. In @Exports annotation you can now declare classes that implement Script interface. During export these classes will be instantiated and method exec will be invoked. This way we can export anything we want. I thought about separate interface but I believe Script really fits in here.

Let me know what you think about it.
Attachment #427652 - Attachment is obsolete: true
Any comments, I still wonder if I should replace Script interface with more specific one.

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.

Attachment

General

Creator:
Created:
Updated:
Size: