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

[Bug] argument type mismatch #996

Open
xenoterracide opened this issue Sep 12, 2024 · 0 comments
Open

[Bug] argument type mismatch #996

xenoterracide opened this issue Sep 12, 2024 · 0 comments

Comments

@xenoterracide
Copy link

xenoterracide commented Sep 12, 2024

Describe the bug

prelude. This is probably an incomplete report, sorry, I plan on coming back to this, but need a stopping point.

the big problem I'm having is "what argument, what are you calling/trying to do?" I'm not certain that what equalsverifier is trying to do is wrong, but rather the error is confusing

Steps to reproduce

... I wish I understood peoples custom bug report templates more, it seems all steps to reproduce asked for later...

Error message and version number

EqualsVerifier found a problem in class com.xenoterracide.model.security.User.
-> argument type mismatch

For more information, go to: https://www.jqno.nl/equalsverifier/errormessages
(EqualsVerifier 3.16.2, JDK 21.0.2 running on classpath, on Linux)
java.lang.AssertionError: EqualsVerifier found a problem in class com.xenoterracide.model.security.User.
-> argument type mismatch

For more information, go to: https://www.jqno.nl/equalsverifier/errormessages
(EqualsVerifier 3.16.2, JDK 21.0.2 running on classpath, on Linux)
	at nl.jqno.equalsverifier.api.SingleTypeEqualsVerifierApi.verify(SingleTypeEqualsVerifierApi.java:354)
	at com.xenoterracide.model.security.UserTest.equality(UserTest.java:45)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:65)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
	at nl.jqno.equalsverifier.internal.reflection.RecordObjectAccessor.lambda$callRecordConstructor$4(RecordObjectAccessor.java:146)
	at nl.jqno.equalsverifier.internal.util.Rethrow.rethrow(Rethrow.java:34)
	at nl.jqno.equalsverifier.internal.reflection.RecordObjectAccessor.callRecordConstructor(RecordObjectAccessor.java:145)
	at nl.jqno.equalsverifier.internal.reflection.RecordObjectAccessor.makeAccessor(RecordObjectAccessor.java:124)
	at nl.jqno.equalsverifier.internal.reflection.RecordObjectAccessor.scramble(RecordObjectAccessor.java:66)
	at nl.jqno.equalsverifier.internal.reflection.ClassAccessor.getRedAccessor(ClassAccessor.java:225)
	at nl.jqno.equalsverifier.internal.reflection.ClassAccessor.getRedObject(ClassAccessor.java:199)
	at nl.jqno.equalsverifier.internal.prefabvalues.factories.FallbackFactory.giveInstances(FallbackFactory.java:99)
	at nl.jqno.equalsverifier.internal.prefabvalues.factories.FallbackFactory.createValues(FallbackFactory.java:40)
	at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.createTuple(PrefabValues.java:189)
	at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.realizeCacheFor(PrefabValues.java:172)
	at nl.jqno.equalsverifier.internal.prefabvalues.factories.AbstractGenericFactory.determineAndCacheActualTypeTag(AbstractGenericFactory.java:56)
	at nl.jqno.equalsverifier.internal.prefabvalues.factories.AbstractGenericFactory.determineAndCacheActualTypeTag(AbstractGenericFactory.java:42)
	at nl.jqno.equalsverifier.internal.prefabvalues.factories.SimpleGenericFactory.createValues(SimpleGenericFactory.java:36)
	at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.createTuple(PrefabValues.java:185)
	at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.realizeCacheFor(PrefabValues.java:172)
	at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.giveTuple(PrefabValues.java:93)
	at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.giveOther(PrefabValues.java:131)
	at nl.jqno.equalsverifier.internal.reflection.FieldModifier.lambda$changeField$2(FieldModifier.java:119)
	at nl.jqno.equalsverifier.internal.reflection.FieldModifier.wrappedChange(FieldModifier.java:140)
	at nl.jqno.equalsverifier.internal.reflection.FieldModifier.lambda$change$3(FieldModifier.java:135)
	at nl.jqno.equalsverifier.internal.util.Rethrow.lambda$rethrow$1(Rethrow.java:51)
	at nl.jqno.equalsverifier.internal.util.Rethrow.rethrow(Rethrow.java:34)
	at nl.jqno.equalsverifier.internal.util.Rethrow.rethrow(Rethrow.java:49)
	at nl.jqno.equalsverifier.internal.util.Rethrow.rethrow(Rethrow.java:59)
	at nl.jqno.equalsverifier.internal.reflection.FieldModifier.change(FieldModifier.java:135)
	at nl.jqno.equalsverifier.internal.reflection.FieldModifier.changeField(FieldModifier.java:122)
	at nl.jqno.equalsverifier.internal.reflection.InPlaceObjectAccessor.scrambleInternal(InPlaceObjectAccessor.java:80)
	at nl.jqno.equalsverifier.internal.reflection.InPlaceObjectAccessor.scramble(InPlaceObjectAccessor.java:58)
	at nl.jqno.equalsverifier.internal.reflection.ClassAccessor.getRedAccessor(ClassAccessor.java:225)
	at nl.jqno.equalsverifier.internal.reflection.ClassAccessor.getRedAccessor(ClassAccessor.java:210)
	at nl.jqno.equalsverifier.internal.reflection.ClassAccessor.getRedObject(ClassAccessor.java:186)
	at nl.jqno.equalsverifier.internal.util.Configuration.ensureUnequalExamples(Configuration.java:219)
	at nl.jqno.equalsverifier.internal.util.Configuration.build(Configuration.java:114)
	at nl.jqno.equalsverifier.api.SingleTypeEqualsVerifierApi.buildConfig(SingleTypeEqualsVerifierApi.java:428)
	at nl.jqno.equalsverifier.api.SingleTypeEqualsVerifierApi.performVerification(SingleTypeEqualsVerifierApi.java:414)
	at nl.jqno.equalsverifier.api.SingleTypeEqualsVerifierApi.verify(SingleTypeEqualsVerifierApi.java:350)
	... 4 more
Caused by: java.lang.ClassCastException: Cannot cast java.lang.Object to com.xenoterracide.model.EntityIdentifier
	at java.base/java.lang.Class.cast(Class.java:4067)
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
	... 43 more


argument type mismatch
java.lang.IllegalArgumentException: argument type mismatch
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:65)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
	at nl.jqno.equalsverifier.internal.reflection.RecordObjectAccessor.lambda$callRecordConstructor$4(RecordObjectAccessor.java:146)
	at nl.jqno.equalsverifier.internal.util.Rethrow.rethrow(Rethrow.java:34)
	at nl.jqno.equalsverifier.internal.reflection.RecordObjectAccessor.callRecordConstructor(RecordObjectAccessor.java:145)
	at nl.jqno.equalsverifier.internal.reflection.RecordObjectAccessor.makeAccessor(RecordObjectAccessor.java:124)
	at nl.jqno.equalsverifier.internal.reflection.RecordObjectAccessor.scramble(RecordObjectAccessor.java:66)
	at nl.jqno.equalsverifier.internal.reflection.ClassAccessor.getRedAccessor(ClassAccessor.java:225)
	at nl.jqno.equalsverifier.internal.reflection.ClassAccessor.getRedObject(ClassAccessor.java:199)
	at nl.jqno.equalsverifier.internal.prefabvalues.factories.FallbackFactory.giveInstances(FallbackFactory.java:99)
	at nl.jqno.equalsverifier.internal.prefabvalues.factories.FallbackFactory.createValues(FallbackFactory.java:40)
	at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.createTuple(PrefabValues.java:189)
	at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.realizeCacheFor(PrefabValues.java:172)
	at nl.jqno.equalsverifier.internal.prefabvalues.factories.AbstractGenericFactory.determineAndCacheActualTypeTag(AbstractGenericFactory.java:56)
	at nl.jqno.equalsverifier.internal.prefabvalues.factories.AbstractGenericFactory.determineAndCacheActualTypeTag(AbstractGenericFactory.java:42)
	at nl.jqno.equalsverifier.internal.prefabvalues.factories.SimpleGenericFactory.createValues(SimpleGenericFactory.java:36)
	at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.createTuple(PrefabValues.java:185)
	at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.realizeCacheFor(PrefabValues.java:172)
	at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.giveTuple(PrefabValues.java:93)
	at nl.jqno.equalsverifier.internal.prefabvalues.PrefabValues.giveOther(PrefabValues.java:131)
	at nl.jqno.equalsverifier.internal.reflection.FieldModifier.lambda$changeField$2(FieldModifier.java:119)
	at nl.jqno.equalsverifier.internal.reflection.FieldModifier.wrappedChange(FieldModifier.java:140)
	at nl.jqno.equalsverifier.internal.reflection.FieldModifier.lambda$change$3(FieldModifier.java:135)
	at nl.jqno.equalsverifier.internal.util.Rethrow.lambda$rethrow$1(Rethrow.java:51)
	at nl.jqno.equalsverifier.internal.util.Rethrow.rethrow(Rethrow.java:34)
	at nl.jqno.equalsverifier.internal.util.Rethrow.rethrow(Rethrow.java:49)
	at nl.jqno.equalsverifier.internal.util.Rethrow.rethrow(Rethrow.java:59)
	at nl.jqno.equalsverifier.internal.reflection.FieldModifier.change(FieldModifier.java:135)
	at nl.jqno.equalsverifier.internal.reflection.FieldModifier.changeField(FieldModifier.java:122)
	at nl.jqno.equalsverifier.internal.reflection.InPlaceObjectAccessor.scrambleInternal(InPlaceObjectAccessor.java:80)
	at nl.jqno.equalsverifier.internal.reflection.InPlaceObjectAccessor.scramble(InPlaceObjectAccessor.java:58)
	at nl.jqno.equalsverifier.internal.reflection.ClassAccessor.getRedAccessor(ClassAccessor.java:225)
	at nl.jqno.equalsverifier.internal.reflection.ClassAccessor.getRedAccessor(ClassAccessor.java:210)
	at nl.jqno.equalsverifier.internal.reflection.ClassAccessor.getRedObject(ClassAccessor.java:186)
	at nl.jqno.equalsverifier.internal.util.Configuration.ensureUnequalExamples(Configuration.java:219)
	at nl.jqno.equalsverifier.internal.util.Configuration.build(Configuration.java:114)
	at nl.jqno.equalsverifier.api.SingleTypeEqualsVerifierApi.buildConfig(SingleTypeEqualsVerifierApi.java:428)
	at nl.jqno.equalsverifier.api.SingleTypeEqualsVerifierApi.performVerification(SingleTypeEqualsVerifierApi.java:414)
	at nl.jqno.equalsverifier.api.SingleTypeEqualsVerifierApi.verify(SingleTypeEqualsVerifierApi.java:350)
	at com.xenoterracide.model.security.UserTest.equality(UserTest.java:45)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: java.lang.ClassCastException: Cannot cast java.lang.Object to com.xenoterracide.model.EntityIdentifier
	at java.base/java.lang.Class.cast(Class.java:4067)
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
	... 43 more


Cannot cast java.lang.Object to com.xenoterracide.model.EntityIdentifier
java.lang.ClassCastException: Cannot cast java.lang.Object to com.xenoterracide.model.EntityIdentifier

note: this gives me a good idea, but no fieldname, and I'm not sure why an object is trying to be casted to that interface atm.

Code: EqualsVerifier invocation

 @Test
  void equality() {
    EqualsVerifier.forClass(User.class)
      .withRedefinedSuperclass()
      .suppress(Warning.SURROGATE_OR_BUSINESS_KEY)
      .withPrefabValues(
        IdentityProviderUser.class,
        IdentityProviderUserTestDataBuilder.create().build(),
        IdentityProviderUserTestDataBuilder.create().build()
      )
      //.withPrefabValues(User.class, UserTestDataBuilder.create().build(), UserTestDataBuilder.create().build())
      .verify();
  }

Code: class under test

I know, this is insufficient and not simple, I'll come back to this part and give you something better.

public interface EntityIdentifier<ID extends @NonNull Serializable, ENTITY extends Identifiable<@NonNull ID>>
  extends Identifiable<@NonNull ID> {
  /**
   * Gets type.
   *
   * @return class of the entity
   */
  @NonNull
  Class<ENTITY> type();
}
  protected void registerEvent(EntityIdentifier<BarEntity.@NonNull Id, @NonNull BarEntity> event) {
    super.registerEvent(FooEvent.create(this.getId(), event));
  }
 private final @Transient List<DomainEvent<?, ID, THIS, ?>> domainEvents = new ArrayList<>();

  /**
   * NO-OP parent constuctor for JPA only.
   */
  protected AbstractAggregate() {}

  /**
   * Instantiates a new Abstract aggregate.
   *
   * @param id the id
   */
  protected AbstractAggregate(@NonNull ID id) {
    super(id);
  }

  /**
   * Registers domain events.
   *
   * @param event the event
   */
  protected void registerEvent(@NonNull DomainEvent<?, ID, THIS, ?> event) {
    this.domainEvents.add(event);
    this.markDirty();
  }

Additional context

I think if the error told me what field path it was trying to create that'd be helpful, the only reason I might be able to figure this out is that it has to be creating a DomainEvent.payload because nothing else has that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant