Skip to content

CodeGenProcessor produces invalid Java source on Eclipse JDT #81

@cstamas

Description

@cstamas

When jdt compiler used (using takari-lifecycle, packaging takari-jar, compilerId jdt), the generated sources are invalid, the package declaration is twice present in source and naturally chokes the compilation.

Edited short snippet from generated code:

...
*/

package package org.cstamas.vertx.orientdb;

import org.cstamas.vertx.orientdb.GraphDatabaseService;
import io.vertx.core.eventbus.DeliveryOptions;
import io.vertx.core.Vertx;
import io.vertx.core.Future;
...

As you see, the line package package org.cstamas.vertx.orientdb; is wrong.

Reason:
As I debugged, it seems that problem lies in ClassModel line 504. The toString() method of JDT implementation org.eclipse.jdt.internal.compiler.apt.model.ElementImpl returns package org.cstamas.vertx.orientdb instead of expected org.cstamas.vertx.orientdb.

So, to make it work on javac but also on jdt compiler, it might be useful to add some check and remove the package prefix if present. Manually verified, that IF one of the two package keywords are removed, the generated code is just fine.

Reproducer: repo at this hash, used mvnDebug w/ remote debugger
https://github.com/cstamas/vertx-orientdb/tree/6062a5b1544a7e1711f3f82a68585085f8742f0a

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions