JamesLuoau / gwt-ent

Automatically exported from code.google.com/p/gwt-ent
0 stars 0 forks source link

unavailable annotations should be handled gracefully #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello!

We are evaluating GwtEnt for our application but found a show-stopper problem.

We have an application which uses annotated JPA entities both at the client
side and the server side.
When

    TypeOracle.Instance.getClassType(type);

is called from our GWT client code, lots of exceptions are thrown at

    com.gwtent.gen.reflection.GeneratorHelper@136

    JClassType classType =
typeOracle.getType(annotation.annotationType().getName());

The cause is that we use JPA (and Hibernate) annotations in our entity
classes (which are used in GWT client code as well), but the sources of
these annotations are not available for the GWT compiler. (The GWT compiler
does not emit eny warnings or errors.)

A solution would be that NotFoundExceptions should be caught by the
corresponding GwtEnt reflection classes, so annotations unavailable for the
GWT compiler should be made unavailable for GwtEnt reflection as well.

This is a show-stopper problem for us, and although GwtEnt seems to be very
good, we cannot use it because of this bug :(

Thanks for your help in advance!
Regards:
Norbi

---

GWT: 1.5.3
GwtEnt: 0.5

Reproducing: call TypeOracle.Instance.getClassType(type) for a type which
has some annotations which are available for the Java compiler but not
available for the GWT compiler.

More complete stack trace:

com.google.gwt.core.ext.typeinfo.NotFoundException: javax.persistence.Entity
        at
com.gwtent.gen.reflection.GeneratorHelper.addAnnotation(GeneratorHelper.java:136
)
        at
com.gwtent.gen.reflection.GeneratorHelper.addAnnotations(GeneratorHelper.java:19
8)
        at
com.gwtent.gen.reflection.ReflectionCreator$ReflectionSourceCreator.addClassAnno
tation(ReflectionCreator.java:212)
        at
com.gwtent.gen.reflection.ReflectionCreator$ReflectionSourceCreator.createSource
(ReflectionCreator.java:183)
        at
com.gwtent.gen.reflection.ReflectAllInOneCreator.genAllClasses(ReflectAllInOneCr
eator.java:72)
        at
com.gwtent.gen.reflection.ReflectAllInOneCreator.createSource(ReflectAllInOneCre
ator.java:53)
        at
com.gwtent.gen.LogableSourceCreator.generate(LogableSourceCreator.java:109)
        at
com.gwtent.gen.reflection.Reflection__ProxyGenerator.generate(Reflection__ProxyG
enerator.java:33)
        at
com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:51)

Original issue reported on code.google.com by norbert_...@hotmail.com on 26 Jan 2009 at 10:10

GoogleCodeExporter commented 9 years ago
Sorry for creating this issue too early, after examining the code I saw that it 
is
already handled:

    } catch (NotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

This System.out.println() made me think that I see a stack trace of dozens of
uncaught exceptions...

I commented out the e.printStackTrace() line, but now I see what is the real 
problem:
a class named com.gwtent.client.reflection.TypeOracle_Visitor is generated 
during the
build and it has a syntax error in the

    public Object java_util_Set.invoke(Object instance, String methodName, Object[] args)

method:

    ...
    } else if (methodName.equals("toArray")) {
          checkInvokeParams(methodName, 0, args);
          return (Object)content.toArray();
    } else if (methodName.equals("toArray")) {
          checkInvokeParams(methodName, 1, args);
          return (Object)content.toArray(((T extends java.lang.Object[])args[0]));
    } else return super.invoke(instance, methodName, args);

This line:

    return (Object)content.toArray(((T extends java.lang.Object[])args[0]));

I hope this is not my fault somehow... :)

Regards:
Norbi

Original comment by norbert_...@hotmail.com on 26 Jan 2009 at 11:43

GoogleCodeExporter commented 9 years ago
Thank you for let me know. The java_util_set stuff already fixed,
you have have a look this link for more information 
http://code.google.com/p/gwt-ent/issues/detail?id=3&can=1

Original comment by JamesLuo...@gmail.com on 7 Mar 2009 at 5:25