f2prateek/dart

Henson class (generated code) compilation error: cannot find symbol

Opened this issue · 3 comments

Sometimes the generated Henson class (DSL) cannot be found when building/compiling the project.
It happens when another special compilation error occurs, but the Henson class shouldn't be affected...

It is a javac problem.
We have reported it and a ticket was created (+1 @stephanenicolas ) :
https://bugs.openjdk.java.net/browse/JDK-8151194

It only happens when one of the following 2 compilations errors occur:

  1. Bad static import: Erroneous static import to a non existing member in an existing class.
import static com.f2prateek.dart.example.SampleActivity.UNEXISTING;
  1. Bad annotation value: Use a symbol that is not defined in as the value of an annotation.
@AnnotationExample(A.B.c) //where A or A.B or A.B.c doesn't exist

We will keep track of the issue here...

It's good to mention here that there is an urban legend about compilation cycles that says : main code should never invoke directly generated code.

But it's just plain wrong. This scenario is fully supported by javac. It is even part of the specs.

The bug in javac that causes the limited issue mentioned here will probably get fixed in javac 9 at some point.

We could create a wrapper for the Henson class till the issue is solved for Java.

This would be optional and the class would be set at runtime, similar to the way TP are set at runtime:
https://github.com/stephanenicolas/toothpick/wiki/Factory-and-Member-Injector-registries

That way we would only have one compilation error: cannot find symbol.

@stephanenicolas WDYT?