[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[qvtd-dev] Java 8 migration
|
Hi
The migration of OCL and QVTd to Java 8 annotations is now complete.
Unfortunately the OCL HIPP (HIPP6) is down so I cannot do the final
check that it is all buildable on Hudson. For now, the two
ewillink/java8 branches are what will probably be pushed to master. You
must use at least JDT 4.5 (Mars) and preferably JDT 4.6M4 to eliminate
some warnings. However we still build with 4.5 on Hudson, so some
warnings are necessary to avoid errors with 4.5. You can detect Hudson
build hazrads by starting up your workspace with Mars.
For the most part it's very beneficial, collections of @NonNull and
@Nullable can now be declared (almost sensibly). The more rational
support eliminates the need for ASM and should make it easier for the CG
to give accurate warning free code; more work to do here.
Syntactically there is one major incompatibility.
@Nullable X[]/List<X> used to mean an array/list that might be null. It
now means an array/list whose elements might be null.
The former meaning is expressed by X @Nullable []/List<@Nullable X>.
The new capability allows @NonNull X @Nullable[] to define an array that
might be null of elements that may not be null.
Very useful for null-free collections as almost all EMF collections area.
Unfortunately EMF collections are not declared null-free yet, so the new
ClassUtil.nullFree(emfCollection) will assert the required cast allowing
List<@NonNull Type> and elimination of the @SuppressWarnings("null") on
the iterator.
-----
Another new facility is the ability to supply external annotations to
'correct' external declarations.
e.g. StringBuilder.toString returns non-null, but is not declared as such.
All plugins specify org.eclipse.ocl.pivot/annotations as their External
Annotation location for which the Ctrl-1 quick fix on the erroneous type
will add an annotation.
Currently
- StringBuilder.toString is annotated eliminating about 20 null warning
suppressions
- IAdapterFactory.getAdapter is annotated eliminating 3 code hazards
Others such as URI.createURI will be steadily added.
Unfortunately there is no multi-location facility yet so they will all
have to be merged into the one pivot location.
-----
EMF does not support Java 8 annotations, or even Java 8 or 7 or 6.
In the past we have got away with JMerge's fortuitous presevation of
manually added annotations. Not quite so easy with Java 8.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=485089
This can be fixed by custom Switch/AdapterFactory templates, but that
only happens reliably for MWE-orchestrated genmodel execution. We
therefore need to ensure that a single "Generate OCL Tests" / "Generate
QVTd Tests" launch generates all test models.
Regards
Ed Willink