Craig Rickle created PYLUCENE-21:
------------------------------------

             Summary: JCC Nested Java Object Access from Python
                 Key: PYLUCENE-21
                 URL: https://issues.apache.org/jira/browse/PYLUCENE-21
             Project: PyLucene
          Issue Type: Question
         Environment: generic
            Reporter: Craig Rickle
            Priority: Minor


Is it possible to access a nested object from python using jcc?

package home;

public class App
{
    public class Embedded {
        public void hello2() {
            System.out.println("hello from App.Embedded method");
        }
    }
        
    public void hello() {
        System.out.println("hello from App method");
    }

    public static void main( String[] args )
    {
        System.out.println( "Hello World!" );
    }
}

Once processed by jcc,

$ python -c "import jcchello;from jcchello import 
initVM,CLASSPATH,App;initVM(classpath=CLASSPATH);a = App();a.hello();"
hello from App method

is ok, but,

$ python -c "import jcchello;from jcchello import 
initVM,CLASSPATH,App;initVM(classpath=CLASSPATH);a = App();a.hello2();"
Traceback (most recent call last):
 File "<string>", line 1, in <module>
AttributeError: 'App' object has no attribute 'hello2'

does not resolve.  We might say, ok, makes sense, lets try to --rename 
home.App\$Embedded=AppEmbedded, then, import an AppEmbedded object, but this 
approach has not worked either in the numerous forms that I have tried.

For completeness, a jar listing follows:
$ jar tf jcc-hello/target/jcc-hello-1.0-SNAPSHOT.jar 
META-INF/
META-INF/MANIFEST.MF
home/
home/App$Embedded.class
home/App.class
META-INF/maven/
META-INF/maven/home/
META-INF/maven/home/jcc-hello/
META-INF/maven/home/jcc-hello/pom.xml
META-INF/maven/home/jcc-hello/pom.properties

In reality, hello2() will effectively be a result set iterator written by an 
external group back to the python caller.  Current thinking is to segment this 
portion of code as a new java method and apply jcc for subsequent integration. 
This would avoid the need to access the nested logic from python, but, would 
require blocking up the resulting data.  Would appreciate any thoughts on this.

Thanks in advance,
Craig


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to