This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: "apply not implemented for PrimProcedure" while attempting to use JNDI


Valtteri Vuorikoski wrote:

>#|kawa:60|# (invoke answer 'has-more)
>java.lang.RuntimeException: apply not implemented for PrimProcedure java.lang.Object com.sun.jndi.ldap.LdapNamingEnumeration.next() - java.lang.IllegalAccessException
>	at gnu.expr.PrimProcedure.applyV(PrimProcedure.java:157)
>	at gnu.mapping.MethodProc.applyN(MethodProc.java:115)
>	at gnu.kawa.reflect.Invoke.applyN(Invoke.java:148)
>	at gnu.kawa.reflect.Invoke.applyN(Invoke.java:49)
>	at gnu.mapping.Procedure.apply(Procedure.java:102)
>	at gnu.mapping.CallContext.run(CallContext.java:183)
>	at gnu.expr.ModuleExp.evalModule(ModuleExp.java:184)
>	at kawa.Shell.run(Shell.java:77)
>	at kawa.Shell.run(Shell.java:32)
>	at kawa.repl.apply0(repl.java:27)
>	at gnu.mapping.Future.run(Future.java:59)
>
>LdapSearchEnumeration is an implementation of javax.naming.NamingEnumeration.
>The search above should return some results. I didn't try with one that doesn't
>(somewhat busy today unfortunately). Javadoc only lists one kind of next()
>for NamingEnumeration (Object next()).
>
I just ran into a similar problem trying to run a servlet (written in 
XQuery compiled
by Kawa) under Tomcat.  The problem is that the implementing class that 
contains
the implementing method is package-private, even though the class 
implements a
public interface (and so the method itself is public).  So invoking the 
"invoke" method
of java.lang.reflect.Method throws an IllegalAccessException.

I think the solution is that when gnu.kawa.reflect.ClassMethods searches 
the class of the
passed-in object it should ignore methods in classes that are not 
public.   This attached patch
does that - it seems to solve my Tomcat problem, but I will probably 
want to clean it
up some before I check it in.

    --Per
Index: ClassMethods.java
===================================================================
RCS file: /cvs/kawa/kawa/gnu/kawa/reflect/ClassMethods.java,v
retrieving revision 1.11
diff -u -r1.11 ClassMethods.java
--- ClassMethods.java	2001/08/30 17:40:05	1.11
+++ ClassMethods.java	2001/11/16 02:47:42
@@ -54,7 +54,7 @@
   {
     MethodFilter filter = new MethodFilter(mname, modifiers, modmask);
     gnu.bytecode.Method[] methods
-      = dtype.getMethods(filter, ! "<init>".equals(mname));
+      = dtype.getMethods(filter, "<init>".equals(mname) ? 0 : 2);
 
     // Remove over-ridden methods.
     int mlength = methods.length;
@@ -220,6 +220,9 @@
   public boolean select(Object value)
   {
     gnu.bytecode.Method method = (gnu.bytecode.Method) value;
+    int classFlags = method.getDeclaringClass().getModifiers();
+    if ((classFlags & Access.PUBLIC) == 0)
+      return false;
     String mname = method.getName();
     return ((method.getModifiers() & modmask) == modifiers)
       && (mname.equals(name) || mname.equals(nameV));      

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]