From: Chris A. <at...@nm...> - 2001-01-22 21:53:28
|
I am running jython 2.0 release on hpux 11 with jdk1.2.2.07. I run my jython interpretter with -Dpython.security.respectJavaAccessibility= 0 and =false. In both cases, I am unable to access protected methods of a class. I just switched out my jar file from using jpython1.1 to jython2.0, and it works under under jpython1.1 My python code looks like the following: print foo.toPrintString(obja, string1, string2) I get the following error: TypeError: toPrintString(): expected 0-2 args; got 3 My java code looks like the following: public class foo extends fooBase { protected String toPrintString(Object obj, String initialIndent, String name) { } } abstract public class fooBase { public String toPrintString() { } public String toPrintString(String initialIndent) { } public String toPrintString(String initialIndent, String name) { } abstract protected String toPrintString(java.lang.Object fooObj, String initialIndent, String name); } |
From: <bc...@wo...> - 2001-01-22 22:37:39
|
[Chris Atkins] >I am running jython 2.0 release on hpux 11 with jdk1.2.2.07. > >I run my jython interpretter >with -Dpython.security.respectJavaAccessibility= 0 and =false. > >In both cases, I am unable to access protected methods of a class. > >I just switched out my jar file from using jpython1.1 to jython2.0, and it >works under under jpython1.1 > >My python code looks like the following: > >print foo.toPrintString(obja, string1, string2) > >I get the following error: >TypeError: toPrintString(): expected 0-2 args; got 3 Well, it works for me. I made some small changes: abstract public class fooBase { public String toPrintString() { return "here1"; } public String toPrintString(String initialIndent) { return "here2"; } public String toPrintString(String initialIndent, String name) { return "here3"; } abstract protected String toPrintString(java.lang.Object fooObj, String initialIndent, String name); } public class foo extends fooBase { protected String toPrintString(Object obj, String initialIndent, String name) { return "here4"; } } jython -Dpython.security.respectJavaAccessibility=false Jython 2.0 on java1.3.0 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> import foo >>> print foo().toPrintString(1, "string1", "string2") here4 >>> regards, finn |
From: Chris A. <at...@nm...> - 2001-01-22 22:59:51
|
It appears that the problem was that the registry had python.security.respectJavaAccessibility = true When I commented this out of the registry file it worked. Can you please explain the difference between: The Java system properties: typically passed in on the command line as options to the java interpreter. Jython properties: Specified on the command line as options to the jython class. See the -D option to the interpreter. I believe the top one says if I place the -D parms before the class name on the java statement as in: java -Dpython.security.respectJavaAccessibility=0 org.python.util.jython The second would be java org.python.util.jython -Dpython.security.respectJavaAccessibility=0 I am embedding jython in my code. How would I pass the -D options to the InteractiveConsole? Chris Atkins > -----Original Message----- > From: Finn Bock [mailto:bc...@wo...] > Sent: Monday, January 22, 2001 4:32 PM > To: jyt...@li... > Cc: at...@nm... > Subject: Re: [Jython-users] Ignoring Java Access > > > [Chris Atkins] > > >I am running jython 2.0 release on hpux 11 with jdk1.2.2.07. > > > >I run my jython interpretter > >with -Dpython.security.respectJavaAccessibility= 0 and =false. > > > >In both cases, I am unable to access protected methods of a class. > > > >I just switched out my jar file from using jpython1.1 to > jython2.0, and it > >works under under jpython1.1 > > > >My python code looks like the following: > > > >print foo.toPrintString(obja, string1, string2) > > > >I get the following error: > >TypeError: toPrintString(): expected 0-2 args; got 3 > > Well, it works for me. I made some small changes: > > abstract public class fooBase { > public String toPrintString() { > return "here1"; > } > public String toPrintString(String initialIndent) { > return "here2"; > } > public String toPrintString(String initialIndent, String name) { > return "here3"; > } > abstract protected String toPrintString(java.lang.Object fooObj, > String initialIndent, String name); > } > > > public class foo extends fooBase { > protected String toPrintString(Object obj, > String initialIndent, String name) { > return "here4"; > } > } > > jython -Dpython.security.respectJavaAccessibility=false > Jython 2.0 on java1.3.0 (JIT: null) > Type "copyright", "credits" or "license" for more information. > >>> import foo > >>> print foo().toPrintString(1, "string1", "string2") > here4 > >>> > > regards, > finn > |
From: <bc...@wo...> - 2001-01-23 15:19:42
|
[Chris Atkins] >It appears that the problem was that the registry had >python.security.respectJavaAccessibility = true > >When I commented this out of the registry file it worked. > > >Can you please explain the difference between: >The Java system properties: typically passed in on the command line as >options to the java interpreter. > >Jython properties: Specified on the command >line as options to the jython class. See the -D option to the interpreter. > >I believe the top one says if I place the -D parms before the class name on >the java statement as in: >java -Dpython.security.respectJavaAccessibility=0 org.python.util.jython > >The second would be >java org.python.util.jython -Dpython.security.respectJavaAccessibility=0 Correct. And because the "registry" file is read in between, it will overwrites the values assigned as system properties. >I am embedding jython in my code. How would I pass the -D options to the >InteractiveConsole? Take a look at 6.2 in the faq: http://jython.sourceforge.net/cgi-bin/faqw.py?req=all#6.2 You can set python.security.respectJavaAccessibility in the same way. It most be done before creating any python objects, including the creation of the interpreter. regards, finn |
From: Chris A. <at...@nm...> - 2001-01-23 18:02:46
|
> > >I am embedding jython in my code. How would I pass the -D > options to the > >InteractiveConsole? > > Take a look at 6.2 in the faq: > > http://jython.sourceforge.net/cgi-bin/faqw.py?req=all#6.2 > > You can set python.security.respectJavaAccessibility in the > same way. It > most be done before creating any python objects, including > the creation > of the interpreter. > In my java code I do the following: java.util.Properties props = System.getProperties(); add properties for other tools with names which do not conflict with python PySystemState.initialize(pyProps, null, s_scriptArgs); I start up my app with PYFLAGS="-Dpython.home=$JPYTHONDIR -Dpython.path=$JPYTHONPATH -D python.cachedir=$JPYTHONCACHEDIR" java -classpath . $PYFLAGS MyClass args This should have place the python properties in both the system properties and set them on the interactive console. According to the rules, it should have picked up the $PYFLAGS over the registry since set on the PySystemState. It instead used what is in the registry. I changed my code to do the following: java.util.Properties pyProps = new java.util.Properties(); pyProps.setProperty("python.security.respectJavaAccessibility", "0"); if (s_scriptArgs == null) s_scriptArgs = new String[0]; PySystemState.initialize(pyProps, null, s_scriptArgs); Now, since I am not setting python.home, python.path, python.cachedir in my java code, they are not being picked up from the system properties set on the command line. Can you explain this? I really want to pick up the properties which have path names from the command line, but the application specific settings such as respectJavaAccessibility from the application. Chris Atkins |
From: <bc...@wo...> - 2001-01-24 11:37:40
|
[Chris Atkins] >I am embedding jython in my code. How would I pass the -D options to the >InteractiveConsole? [finn] > Take a look at 6.2 in the faq: > > http://jython.sourceforge.net/cgi-bin/faqw.py?req=all#6.2 > > You can set python.security.respectJavaAccessibility in the same way. It > most be done before creating any python objects, including the creation > of the interpreter. [back to Chris] >In my java code I do the following: > java.util.Properties props = System.getProperties(); >add properties for other tools with names which do not conflict with python > PySystemState.initialize(pyProps, null, s_scriptArgs); Is pyProps a typo? I guess you mean props. >I start up my app with >PYFLAGS="-Dpython.home=$JPYTHONDIR -Dpython.path=$JPYTHONPATH -D >python.cachedir=$JPYTHONCACHEDIR" > >java -classpath . $PYFLAGS MyClass args > >This should have place the python properties in both the system properties >and set them on the interactive console. According to the rules, it should >have picked up the $PYFLAGS over the registry No. The rules on the registry.html says Jython properties > registry files > System.properties. i.e. the registry files will typically be searched before the System.properties. >since set on the PySystemState. That makes no difference. The org.python.util.jython class also calls initialize with: PySystemState.initialize(System.getProperties(), opts.properties, opts.argv); where opts.properties contains the -D options found as argument to jython class (aka Jython properties). >It instead used what is in the registry. Right. In your examples, the value for jython properties is null (meaning empty) so the registry files is searched first. Only if nothing is found there is the System.properties searched. >I changed my code to do the following: > > java.util.Properties pyProps = new java.util.Properties(); > pyProps.setProperty("python.security.respectJavaAccessibility", "0"); > if (s_scriptArgs == null) s_scriptArgs = new String[0]; > PySystemState.initialize(pyProps, null, s_scriptArgs); I guess this will do most of what you're after: java.util.Properties pyProps = new java.util.Properties(); # Insert selected (or maybe all?) System.properties into # jython properties. String s = System.getProperty("python.home"); if (s != null) pyProps.setProperty("python.home", s); s = System.getProperty("python.path"); if (s != null) pyProps.setProperty("python.path", s); s = System.getProperty("python.cachedir"); if (s != null) pyProps.setProperty("python.cachedir", s); # Set some application properties. pyProps.setProperty("python.security.respectJavaAccessibility", "0"); PySystemState.initialize(System.getProperties(), pyProps, s_scriptArgs); >Can you explain this? I hope the above helps. All in all, I think the property lookup mechanism as mostly Ok. Perhaps we should have a way of changing the lookup priority since I guess you would rather use: Jython properties > System.properties > registry files OTOH we shouldn't make it more complicated for novices. The only real drawback I know off, is the use of the -D command line option for jython properties. This is commonly used by the java command as well and that can be confusing. regards, finn |