Merge pull request #142 from tennysonholloway/master
Fix Nashorn error: has no such function getHandlerList.
This commit is contained in:
commit
4d6d444d53
1 changed files with 12 additions and 13 deletions
|
@ -108,21 +108,20 @@ exports.on = function(
|
||||||
} else {
|
} else {
|
||||||
priority = bkEventPriority[priority.toUpperCase()];
|
priority = bkEventPriority[priority.toUpperCase()];
|
||||||
}
|
}
|
||||||
if ( typeof eventType == 'string' ) {
|
|
||||||
/*
|
|
||||||
Nashorn doesn't support bracket notation for accessing packages.
|
|
||||||
E.g. java.net will work but java['net'] won't.
|
|
||||||
|
|
||||||
https://bugs.openjdk.java.net/browse/JDK-8031715
|
|
||||||
*/
|
|
||||||
if ( typeof Java != 'undefined' ) {
|
if ( typeof Java != 'undefined' ) {
|
||||||
// nashorn environment
|
//Nashorn doesn't like when getHandlerList is in a superclass of your event
|
||||||
eventType = Java.type( bkEventPackage + eventType );
|
//so to avoid this problem, call getHandlerList using java.lang.reflect
|
||||||
} else {
|
//methods
|
||||||
|
handlerList = java.lang.Class.forName(bkEventPackage + '' + eventType)
|
||||||
|
.getMethod("getHandlerList").invoke(null);
|
||||||
|
//rhino environment doesn't have this issue.
|
||||||
|
} else if ( typeof eventType == 'string' ) {
|
||||||
eventType = eval( bkEventPackage + eventType );
|
eventType = eval( bkEventPackage + eventType );
|
||||||
}
|
|
||||||
}
|
|
||||||
handlerList = eventType.getHandlerList( );
|
handlerList = eventType.getHandlerList( );
|
||||||
|
} else {
|
||||||
|
handlerList = eventType.getHandlerList( );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var result = { };
|
var result = { };
|
||||||
eventExecutor = new bkEventExecutor( {
|
eventExecutor = new bkEventExecutor( {
|
||||||
|
|
Reference in a new issue