Fix for AVATAR_JS-158, handle JS Object with null prototype

This commit is contained in:
jfdenise 2014-01-13 18:58:59 +01:00
parent 16bfaa6fba
commit fda778d3c8
2 changed files with 11 additions and 7 deletions

View File

@ -1,5 +1,5 @@
--- ../node/lib/repl.js 2013-12-16 17:07:31.000000000 +0100
+++ ./src/main/js/lib/repl.js 2014-01-13 15:40:15.000000000 +0100
+++ src/main/js/lib/repl.js 2014-01-13 18:56:58.000000000 +0100
@@ -236,6 +236,8 @@
// First we attempt to eval as expression with parens.
@ -19,14 +19,16 @@
} else {
finish(null);
@@ -565,7 +570,18 @@
@@ -565,7 +570,20 @@
if (obj != null) {
if (typeof obj === 'object' || typeof obj === 'function') {
+ try {
memberGroups.push(Object.getOwnPropertyNames(obj));
+ } catch(err) {
+ if ((typeof(obj) == 'object' || typeof(obj) == 'function') && !(obj instanceof Object)) { // Completion on java
+ if (typeof(obj.__proto__) === 'undefined' &&
+ (typeof(obj) == 'object' || typeof(obj) == 'function') &&
+ !(obj instanceof Object)) { // Completion on java
+ var arr = obj.class.getMethods()
+ var methods = [];
+ for (var m in arr) {
@ -38,7 +40,7 @@
}
// works for non-objects
try {
@@ -923,5 +939,5 @@
@@ -923,5 +941,5 @@
// "strict mode" syntax errors
!e.match(/^SyntaxError: .*strict mode.*/i) &&
// JSON.parse() error

View File

@ -1,11 +1,13 @@
--- ../node/lib/util.js 2013-12-09 10:27:58.000000000 +0100
+++ ./src/main/js/lib/util.js 2014-01-13 15:51:02.000000000 +0100
@@ -218,6 +218,12 @@
+++ src/main/js/lib/util.js 2014-01-13 18:53:58.000000000 +0100
@@ -218,6 +218,14 @@
return primitive;
}
+ // Java thing, can be a Dynalink function, a java instance, a java class
+ if ((typeof(value) == 'object' || typeof(value) == 'function') && !(value instanceof Object)) { // java
+ if (typeof(value.__proto__) === 'undefined' &&
+ (typeof(value) == 'object' || typeof(value) == 'function') &&
+ !(value instanceof Object)) { // java
+ // equivalent to toString whatever toString exists or not
+ return "" + value;
+ }