将 Lombok NonNull 注释添加到 JDO 实体字段后编译失败
基于 Apache Isis 2 SimpleApp JDO 项目 (https://github.com/ apache/isis-app-simpleapp/tree/jdo)我尝试稍微修改 SimpleObject
类来标记一些字段(name
和 notes< /代码>) 作为使用 Lombok 注释
@NonNull
不能为空。这意外地导致编译失败
Error: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project simpleapp-jdo-module-simple: Compilation failure: Compilation failure:
Error: /home/runner/work/isis-app-simpleapp/isis-app-simpleapp/module-simple/target/generated-sources/annotations/domainapp/modules/simple/dom/so/QSimpleObject.java:[35,51] cannot find symbol
Error: symbol: class java
Error: location: class domainapp.modules.simple.dom.so.QSimpleObject
Error: /home/runner/work/isis-app-simpleapp/isis-app-simpleapp/module-simple/target/generated-sources/annotations/domainapp/modules/simple/dom/so/QSimpleObject.java:[36,51] cannot find symbol
Error: symbol: class java
Error: location: class domainapp.modules.simple.dom.so.QSimpleObject
Error: -> [Help 1]
相关 GitHub 操作: https://github .com/a-st/isis-app-simpleapp/runs/5330590432
DataNucleus 生成的类isis-app-simpleapp/module-simple/target/ generated-sources/annotations/domainapp/modules/simple/dom/so/QSimpleObject.java
看起来像这样
package domainapp.modules.simple.dom.so;
import javax.annotation.Generated;
import javax.jdo.query.*;
import org.datanucleus.api.jdo.query.*;
@Generated(value="org.datanucleus.jdo.query.JDOQueryProcessor")
public class QSimpleObject extends PersistableExpressionImpl<SimpleObject> implements PersistableExpression<SimpleObject>
{
public static final QSimpleObject jdoCandidate = candidate("this");
public static QSimpleObject candidate(String name)
{
return new QSimpleObject(null, name, 5);
}
public static QSimpleObject candidate()
{
return jdoCandidate;
}
public static QSimpleObject parameter(String name)
{
return new QSimpleObject(SimpleObject.class, name, ExpressionType.PARAMETER);
}
public static QSimpleObject variable(String name)
{
return new QSimpleObject(SimpleObject.class, name, ExpressionType.VARIABLE);
}
public final ObjectExpression<org.apache.isis.applib.services.repository.RepositoryService> repositoryService;
public final ObjectExpression<org.apache.isis.applib.services.title.TitleService> titleService;
public final ObjectExpression<org.apache.isis.applib.services.message.MessageService> messageService;
public final ObjectExpression<@lombok.NonNull java.lang.String> name;
public final ObjectExpression<@lombok.NonNull java.lang.String> notes;
public QSimpleObject(PersistableExpression parent, String name, int depth)
{
super(parent, name);
this.repositoryService = new ObjectExpressionImpl<org.apache.isis.applib.services.repository.RepositoryService>(this, "repositoryService");
this.titleService = new ObjectExpressionImpl<org.apache.isis.applib.services.title.TitleService>(this, "titleService");
this.messageService = new ObjectExpressionImpl<org.apache.isis.applib.services.message.MessageService>(this, "messageService");
this.name = new StringExpressionImpl(this, "name");
this.notes = new StringExpressionImpl(this, "notes");
}
public QSimpleObject(Class type, String name, ExpressionType exprType)
{
super(type, name, exprType);
this.repositoryService = new ObjectExpressionImpl<org.apache.isis.applib.services.repository.RepositoryService>(this, "repositoryService");
this.titleService = new ObjectExpressionImpl<org.apache.isis.applib.services.title.TitleService>(this, "titleService");
this.messageService = new ObjectExpressionImpl<org.apache.isis.applib.services.message.MessageService>(this, "messageService");
this.name = new StringExpressionImpl(this, "name");
this.notes = new StringExpressionImpl(this, "notes");
}
}
根据 Visual Studio Code,以下几行是导致问题(非法放置注释:类型注释必须直接位于它们要影响的类型的简单名称之前(或 []数组)Java(1610613796)
)
public final ObjectExpression<@lombok.NonNull java.lang.String> name;
public final ObjectExpression<@lombok.NonNull java.lang.String> notes;
源代码位于 https://github.com/a-st/isis-应用程序-simpleapp/tree/jdo-lombok-nonnull
Based on the Apache Isis 2 SimpleApp JDO project (https://github.com/apache/isis-app-simpleapp/tree/jdo) I tried to slightly modify the SimpleObject
class to mark some fields (name
and notes
) as not nullable using the Lombok annotation @NonNull
. This unexpectedly results in a compilation failure
Error: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project simpleapp-jdo-module-simple: Compilation failure: Compilation failure:
Error: /home/runner/work/isis-app-simpleapp/isis-app-simpleapp/module-simple/target/generated-sources/annotations/domainapp/modules/simple/dom/so/QSimpleObject.java:[35,51] cannot find symbol
Error: symbol: class java
Error: location: class domainapp.modules.simple.dom.so.QSimpleObject
Error: /home/runner/work/isis-app-simpleapp/isis-app-simpleapp/module-simple/target/generated-sources/annotations/domainapp/modules/simple/dom/so/QSimpleObject.java:[36,51] cannot find symbol
Error: symbol: class java
Error: location: class domainapp.modules.simple.dom.so.QSimpleObject
Error: -> [Help 1]
Related GitHub Action: https://github.com/a-st/isis-app-simpleapp/runs/5330590432
The DataNucleus generated class isis-app-simpleapp/module-simple/target/generated-sources/annotations/domainapp/modules/simple/dom/so/QSimpleObject.java
looks like this
package domainapp.modules.simple.dom.so;
import javax.annotation.Generated;
import javax.jdo.query.*;
import org.datanucleus.api.jdo.query.*;
@Generated(value="org.datanucleus.jdo.query.JDOQueryProcessor")
public class QSimpleObject extends PersistableExpressionImpl<SimpleObject> implements PersistableExpression<SimpleObject>
{
public static final QSimpleObject jdoCandidate = candidate("this");
public static QSimpleObject candidate(String name)
{
return new QSimpleObject(null, name, 5);
}
public static QSimpleObject candidate()
{
return jdoCandidate;
}
public static QSimpleObject parameter(String name)
{
return new QSimpleObject(SimpleObject.class, name, ExpressionType.PARAMETER);
}
public static QSimpleObject variable(String name)
{
return new QSimpleObject(SimpleObject.class, name, ExpressionType.VARIABLE);
}
public final ObjectExpression<org.apache.isis.applib.services.repository.RepositoryService> repositoryService;
public final ObjectExpression<org.apache.isis.applib.services.title.TitleService> titleService;
public final ObjectExpression<org.apache.isis.applib.services.message.MessageService> messageService;
public final ObjectExpression<@lombok.NonNull java.lang.String> name;
public final ObjectExpression<@lombok.NonNull java.lang.String> notes;
public QSimpleObject(PersistableExpression parent, String name, int depth)
{
super(parent, name);
this.repositoryService = new ObjectExpressionImpl<org.apache.isis.applib.services.repository.RepositoryService>(this, "repositoryService");
this.titleService = new ObjectExpressionImpl<org.apache.isis.applib.services.title.TitleService>(this, "titleService");
this.messageService = new ObjectExpressionImpl<org.apache.isis.applib.services.message.MessageService>(this, "messageService");
this.name = new StringExpressionImpl(this, "name");
this.notes = new StringExpressionImpl(this, "notes");
}
public QSimpleObject(Class type, String name, ExpressionType exprType)
{
super(type, name, exprType);
this.repositoryService = new ObjectExpressionImpl<org.apache.isis.applib.services.repository.RepositoryService>(this, "repositoryService");
this.titleService = new ObjectExpressionImpl<org.apache.isis.applib.services.title.TitleService>(this, "titleService");
this.messageService = new ObjectExpressionImpl<org.apache.isis.applib.services.message.MessageService>(this, "messageService");
this.name = new StringExpressionImpl(this, "name");
this.notes = new StringExpressionImpl(this, "notes");
}
}
According to Visual Studio Code the following lines are causing issues (Illegally placed annotation: type annotations must directly precede the simple name of the type they are meant to affect (or the [] for arrays)Java(1610613796)
)
public final ObjectExpression<@lombok.NonNull java.lang.String> name;
public final ObjectExpression<@lombok.NonNull java.lang.String> notes;
The source code is located at https://github.com/a-st/isis-app-simpleapp/tree/jdo-lombok-nonnull
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题似乎与 https://github.com/datanucleus/datanucleus- 有关jdo-query/issues/18 并通过指定解决
Issue seems to be related to https://github.com/datanucleus/datanucleus-jdo-query/issues/18 and is solved with specifying