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

Intermediate generic parent scenario: Don't know how to extract Class from type 'ID'. #501

Closed
prook opened this Issue Feb 22, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@prook

prook commented Feb 22, 2017

Consider the following class hierarchy, note the ID type parameter in particular:

class Identified<ID> {
    ID id;
}

class Versioned<ID, VER> extends Identified<ID> {
    VER version;
}

class Person extends Versioned<Long, Long> {
    String name;
}

class PersonTest {
    @Test
    public void testCompare() {
        Javers javers = JaversBuilder.javers().build();
        javers.compare(new Person(), new Person());
    }
}

Instead of resolving ID to Long, JaVers blows up:

o.j.c.m.t.TypeMapper - Can't calculate JaversType for property: Field ID id; //declared in Identified

JaversException CLASS_EXTRACTION_ERROR: JaVers bootstrap error - Don't know how to extract Class from type 'ID'.

at org.javers.common.reflection.ReflectionUtil.extractClass(ReflectionUtil.java:216)
at org.javers.core.metamodel.type.TypeMapperState.findNearestAncestor(TypeMapperState.java:156)
at org.javers.core.metamodel.type.TypeMapperState.infer(TypeMapperState.java:149)
at org.javers.core.metamodel.type.TypeMapperState.lambda$getJaversType$18(TypeMapperState.java:86)
at org.javers.core.metamodel.type.TypeMapperState.computeIfAbsent(TypeMapperState.java:107)
at org.javers.core.metamodel.type.TypeMapperState.getJaversType(TypeMapperState.java:86)
at org.javers.core.metamodel.type.TypeMapper.getJaversType(TypeMapper.java:100)
at org.javers.core.metamodel.type.TypeMapper.getPropertyType(TypeMapper.java:165)
at org.javers.core.graph.ObjectGraphBuilder.lambda$getSingleReferencesWithManagedTypes$43(ObjectGraphBuilder.java:107)
at org.javers.core.metamodel.type.ManagedClass.getManagedProperties(ManagedClass.java:65)
at org.javers.core.metamodel.type.ManagedType.getProperties(ManagedType.java:49)
at org.javers.core.graph.ObjectGraphBuilder.getSingleReferencesWithManagedTypes(ObjectGraphBuilder.java:106)
at org.javers.core.graph.ObjectGraphBuilder.buildSingleEdges(ObjectGraphBuilder.java:76)
at org.javers.core.graph.ObjectGraphBuilder.buildEdges(ObjectGraphBuilder.java:71)
at org.javers.core.graph.ObjectGraphBuilder.buildGraphFromCdo(ObjectGraphBuilder.java:59)
at org.javers.core.graph.ObjectGraphBuilder.buildGraph(ObjectGraphBuilder.java:48)
at org.javers.core.graph.LiveGraphFactory.createLiveGraph(LiveGraphFactory.java:39)
at org.javers.core.diff.DiffFactory.buildGraph(DiffFactory.java:101)
at org.javers.core.diff.DiffFactory.compare(DiffFactory.java:56)
at org.javers.core.JaversCore.compare(JaversCore.java:127)

Observed in JaVers 2.9.2 and 3.0.0.

@prook prook changed the title from CLASS_EXTRACTION_ERROR: Don't know how to extract Class from type 'ID' to Intermediate generic parent scenario: Don't know how to extract Class from type 'ID'. Feb 23, 2017

bartoszwalacik added a commit that referenced this issue Feb 24, 2017

#501
error reproduction

@bartoszwalacik bartoszwalacik added the bug label Feb 24, 2017

bartoszwalacik added a commit that referenced this issue Feb 26, 2017

#501
fixes
@bartoszwalacik

This comment has been minimized.

Member

bartoszwalacik commented Mar 3, 2017

fixed in 3.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment