Fix Nashorn error: has no such function getHandlerList.
This commit is contained in:
parent
20519d88db
commit
553bec363b
1 changed files with 12 additions and 13 deletions
|
@ -108,21 +108,20 @@ exports.on = function(
|
|||
} else {
|
||||
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' ) {
|
||||
// nashorn environment
|
||||
eventType = Java.type( bkEventPackage + eventType );
|
||||
} else {
|
||||
if ( typeof Java != 'undefined' ) {
|
||||
//Nashorn doesn't like when getHandlerList is in a superclass of your event
|
||||
//so to avoid this problem, call getHandlerList using java.lang.reflect
|
||||
//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 );
|
||||
}
|
||||
handlerList = eventType.getHandlerList( );
|
||||
} else {
|
||||
handlerList = eventType.getHandlerList( );
|
||||
}
|
||||
handlerList = eventType.getHandlerList( );
|
||||
|
||||
|
||||
var result = { };
|
||||
eventExecutor = new bkEventExecutor( {
|
||||
|
|
Reference in a new issue