Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with @Criteria.Repository on Eclipse #1175

Closed
ralscha opened this issue May 4, 2020 · 10 comments
Closed

Problem with @Criteria.Repository on Eclipse #1175

ralscha opened this issue May 4, 2020 · 10 comments
Labels
criteria issues related to Criteria DSL and evaluation

Comments

@ralscha
Copy link

ralscha commented May 4, 2020

I'm dabbling a bit with @Criteria and it does not work with the Eclipse compiler.

I created a demo project to demonstrate the issue:
https://github.com/ralscha/immutables

The project works fine on the command line and the OpenJDK compiler. But when you import that project into Eclipse it generates an "empty" Repository implementation

@Value.Immutable
@Criteria
@Criteria.Repository
interface Person {
  @Criteria.Id
  String id();
  String fullName();
}

"Empty" Repository without any methods

class PersonRepository implements Repository<Person>{
  private final Backend backend;
  public PersonRepository(Backend backend) {
    this.backend = Objects.requireNonNull(backend, "backend");
  }
}

As a second test I added the default facets.

@Value.Immutable
@Criteria
@Criteria.Repository(facets = {SyncReadable.class, SyncWritable.class})
interface Person {
  @Criteria.Id
  String id();

  String fullName();
}

With this change the Eclipse compiler no longer generates PersonRepository and instead throws this error

org.immutables.value.internal.$processor$.$Processor threw java.lang.IllegalArgumentException: element public default org.immutables.criteria.backend.WriteResult upsert(T)  is not a member of the containing type org.immutables.criteria.repository.sync.SyncRepository.Writable<ch.rasc.immutables.Person> nor any of its superclasses
	at org.eclipse.jdt.internal.compiler.apt.model.TypesImpl.asMemberOf(TypesImpl.java:190)
	at org.immutables.value.internal.$processor$.meta.$RepositoryModel$FacetConsumer.consume($RepositoryModel.java:165)
	at org.immutables.value.internal.$processor$.meta.$RepositoryModel.facets($RepositoryModel.java:81)
	at 

Not sure if that is a bug in the Eclipse compiler.

@elucash
Copy link
Member

elucash commented May 4, 2020

It's not the first time we have problems with Types.asMemberOf implementation discrepancies between Javac and ECJ, @asereda-gs when you have time, can you take a look. I'm trying to remember how we work around it.... so it was something like this: if this is javac we use asMemberOf to resolve type parameters, but for ECJ we use Elements.getAllMembers which resolves type variables instead (but not for javac, hence asMemberOf)

@asereda-gs
Copy link
Member

I will take a look. @ralscha what version of Eclipse are you using ?

@asereda-gs asereda-gs added the criteria issues related to Criteria DSL and evaluation label May 4, 2020
@ralscha
Copy link
Author

ralscha commented May 5, 2020

The latest version Eclipse IDE 2020‑03

@asereda-gs
Copy link
Member

@ralscha I'm working on Immutables release now (which should happen this week).
Will take a look at this issue as soon as I am done.

@realumhelp
Copy link

Any updates on this? I seem to be having a similar issue with Eclipse 2020-09 /w JDK11. Building via Eclipse will generate a Repository with only a constructor as @ralscha shows. However, when I build via command line it seems to properly build the Repository classes.

My current work-around seems to be building via command line and refreshing my Eclipse project to see the properly generated classes. Eclipse picks them up and seems to run with them just fine, but it is very annoying to have to constantly build from command line. Any resolution would be awesome!!

@elucash
Copy link
Member

elucash commented Oct 8, 2020

Need to take a look, hopefully can dedicate some time this weekend. Sorry for late responses etc, very busy overall...

@moledzki
Copy link

moledzki commented Oct 9, 2021

Any updates on this?

@vagtsi
Copy link

vagtsi commented Oct 25, 2021

@Criteria.Repository still not usable due to this error on Eclipse 2021-09 with JDK14 and Immutables 2.8.8!

@asereda-gs
Copy link
Member

This should be fixed in the last commit. Is there a way for you to build your project from immutables master ?

@vagtsi
Copy link

vagtsi commented Feb 17, 2022

Hi @asereda-gs , I can confirm, this issue is fixed! I successful tested the criteria Quick Start code in Eclipse 2021-12 (4.22.0) with recent immutables 2.9.0.
Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
criteria issues related to Criteria DSL and evaluation
Projects
None yet
Development

No branches or pull requests

6 participants