|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
How to use java annotation in Jython subclassHi all
As title, How to use java annotations in a jython subclass?
I am using Jython 2.5rc3 on jdk 1.6
thanks!
BRs//James Deng
------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: How to use java annotation in Jython subclassI guess you'll have to be a bit more specific, as to what you want to achieve. Do you want to
* annotate a method on a jython subclass (parent class is java)? * access the annotation of a method (or class) declared in the java superclass (or somewhere else). The first case is probably not solved yet (at least according to the bugtracker [1], that means that there's no possibility to declare annotations in your Jython code The second case can be achieved with generics, just as you would in Java (your annotations have to be declared with RetentionPolicy.RUNTIME). Check [2] for a good summary. Summary: Declaration inside Jython is probably not going to work, Access at runtime can be achieved in the same way as in Java, through Reflection (it's a Java class, not even a Jython class). Cheers, Daniel [1] http://bugs.jython.org/issue1080 [2] http://www.eclipse.org/aspectj/doc/released/adk15notebook/annotations.html#annotations-inJava5 On Sun, May 31, 2009 at 4:02 PM, James Deng <jtdeng@...> wrote:
------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
|
|
Re: How to use java annotation in Jython subclassHi Daniel
Sorry for the ambiguity, but really appreciate that your answer has covered both questions.
actually I was trying to use jython 2.5 rc3 with restlet-2.0, in restlet2.0, there is an annotation declared in java like below
===========Get.java==================
package org.restlet.resource;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.restlet.engine.Method;
/**
* Annotation for methods that retrieve a resource representation. Its semantics * is equivalent to an HTTP GET method.<br> * <br> * Note: The current implementation isn't complete and doesn't support the full * syntax. This is work in progress and should only be used for experimentation. * * @author Jerome Louvel */ @Documented @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) @Method("GET") public @interface Get { String value() default "";
}
then I want to subclass a restlet resource from java class ServerResource
==========HelloWorldResource.py==============
from org.restlet.resource import Get
from org.restlet.resource import ServerResource class HelloWorldResource(ServerResource):
def __init__(self): ServerResource.__init__(self) @Get def represent(self):
return 'Hello, world!' I got this error when I run this piece of code.
@Get
TypeError: No visible constructors for class (org.restlet.resource.Get) that means, for a Jython class, I can not use the annotation declared in java. that just hit the jython bug http://bugs.jython.org/issue1080 which you mentioned.
Do you think there is anyway to walk around it?
thanks a lot!
BRs//James Deng
On Sun, May 31, 2009 at 7:10 PM, Daniel <dan.in.a.bottle@...> wrote: I guess you'll have to be a bit more specific, as to what you want to achieve. Do you want to ------------------------------------------------------------------------------ Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT is a gathering of tech-side developers & brand creativity professionals. Meet the minds behind Google Creative Lab, Visual Complexity, Processing, & iPhoneDevCamp as they present alongside digital heavyweights like Barbarian Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com _______________________________________________ Jython-users mailing list Jython-users@... https://lists.sourceforge.net/lists/listinfo/jython-users |
| Free embeddable forum powered by Nabble | Forum Help |