Merge pull request #142 from tennysonholloway/master

Fix Nashorn error: has no such function getHandlerList.
This commit is contained in:
Walter Higgins 2014-06-06 18:30:44 +01:00
commit 4d6d444d53

View file

@ -108,21 +108,20 @@ exports.on = function(
} else { } else {
priority = bkEventPriority[priority.toUpperCase()]; priority = bkEventPriority[priority.toUpperCase()];
} }
if ( typeof eventType == 'string' ) { if ( typeof Java != 'undefined' ) {
/* //Nashorn doesn't like when getHandlerList is in a superclass of your event
Nashorn doesn't support bracket notation for accessing packages. //so to avoid this problem, call getHandlerList using java.lang.reflect
E.g. java.net will work but java['net'] won't. //methods
handlerList = java.lang.Class.forName(bkEventPackage + '' + eventType)
https://bugs.openjdk.java.net/browse/JDK-8031715 .getMethod("getHandlerList").invoke(null);
*/ //rhino environment doesn't have this issue.
if ( typeof Java != 'undefined' ) { } else if ( typeof eventType == 'string' ) {
// nashorn environment
eventType = Java.type( bkEventPackage + eventType );
} else {
eventType = eval( bkEventPackage + eventType ); eventType = eval( bkEventPackage + eventType );
} handlerList = eventType.getHandlerList( );
} else {
handlerList = eventType.getHandlerList( );
} }
handlerList = eventType.getHandlerList( );
var result = { }; var result = { };
eventExecutor = new bkEventExecutor( { eventExecutor = new bkEventExecutor( {