]> granicus.if.org Git - php/commitdiff
Allow non-public enumerations to be accessed
authorSam Ruby <rubys@php.net>
Thu, 17 Feb 2000 06:44:14 +0000 (06:44 +0000)
committerSam Ruby <rubys@php.net>
Thu, 17 Feb 2000 06:44:14 +0000 (06:44 +0000)
ext/java/reflect.java
ext/rpc/java/reflect.java

index b282aa0932f263698a11bec41a8051699769c361..52d39857db2554667db7f2ac4ad6fb753f1b06d5 100644 (file)
@@ -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();
 
index b282aa0932f263698a11bec41a8051699769c361..52d39857db2554667db7f2ac4ad6fb753f1b06d5 100644 (file)
@@ -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();