diff --git a/ext/java/reflect.java b/ext/java/reflect.java index b282aa0932f..52d39857db2 100644 --- a/ext/java/reflect.java +++ b/ext/java/reflect.java @@ -197,6 +197,23 @@ class reflect { public static void Invoke (Object object, String method, Object args[], long result) { + + // Apparently, if a class is not declared "public" it is illegal to + // access a method of this class via Invoke. We can't work around + // all such cases, but enumeration does appear to be a common case. + if (object instanceof Enumeration && args.length == 0) { + + if (method.equalsIgnoreCase("hasMoreElements")) { + setResultFromBoolean(result, ((Enumeration)object).hasMoreElements()); + return; + } + + if (method.equalsIgnoreCase("nextElement")) { + setResultFromObject(result, ((Enumeration)object).nextElement()); + return; + } + } + try { Vector matches = new Vector(); diff --git a/ext/rpc/java/reflect.java b/ext/rpc/java/reflect.java index b282aa0932f..52d39857db2 100644 --- a/ext/rpc/java/reflect.java +++ b/ext/rpc/java/reflect.java @@ -197,6 +197,23 @@ class reflect { public static void Invoke (Object object, String method, Object args[], long result) { + + // Apparently, if a class is not declared "public" it is illegal to + // access a method of this class via Invoke. We can't work around + // all such cases, but enumeration does appear to be a common case. + if (object instanceof Enumeration && args.length == 0) { + + if (method.equalsIgnoreCase("hasMoreElements")) { + setResultFromBoolean(result, ((Enumeration)object).hasMoreElements()); + return; + } + + if (method.equalsIgnoreCase("nextElement")) { + setResultFromObject(result, ((Enumeration)object).nextElement()); + return; + } + } + try { Vector matches = new Vector();