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

2.0.0-RC1 does not work with complex objects #380

Closed
pranasblk opened this issue Jun 9, 2016 · 6 comments
Closed

2.0.0-RC1 does not work with complex objects #380

pranasblk opened this issue Jun 9, 2016 · 6 comments
Labels

Comments

@pranasblk
Copy link

@pranasblk pranasblk commented Jun 9, 2016

Result: 13:23:09.398 [main] INFO  o.j.j.Java8AddOns - loading Java8 add-ons ...
13:23:09.420 [main] INFO  o.j.g.GroovyAddOns - loading Groovy add-ons ...
13:23:09.425 [main] INFO  o.j.c.m.s.ScannerModule - using FIELD mappingStyle
13:23:09.484 [main] INFO  o.j.c.JaversBuilder - using fake InMemoryRepository, register actual implementation via JaversBuilder.registerJaversRepository()
13:23:09.506 [main] INFO  o.j.c.JaversBuilder - JaVers instance is up & ready
JaversException: CLASS_EXTRACTION_ERROR JaVers bootstrap error - Don't know how to extract Class from type 'T[]'.
    at org.javers.common.reflection.ReflectionUtil.extractClass(ReflectionUtil.java:207)
    at org.javers.core.metamodel.type.TypeMapperState.findNearestAncestor(TypeMapperState.java:167)
    at org.javers.core.metamodel.type.TypeMapperState.infer(TypeMapperState.java:160)
    at org.javers.core.metamodel.type.TypeMapperState.access$000(TypeMapperState.java:23)
    at org.javers.core.metamodel.type.TypeMapperState$1.apply(TypeMapperState.java:87)
    at org.javers.core.metamodel.type.TypeMapperState$1.apply(TypeMapperState.java:85)
    at org.javers.core.metamodel.type.TypeMapperState.computeIfAbsent(TypeMapperState.java:118)
    at org.javers.core.metamodel.type.TypeMapperState.getJaversType(TypeMapperState.java:85)
    at org.javers.core.metamodel.type.TypeMapper.getJaversType(TypeMapper.java:101)
    at org.javers.core.metamodel.type.TypeMapper.getPropertyType(TypeMapper.java:165)
    at org.javers.core.graph.ObjectGraphBuilder$1.apply(ObjectGraphBuilder.java:108)
    at org.javers.core.graph.ObjectGraphBuilder$1.apply(ObjectGraphBuilder.java:106)
    at org.javers.core.metamodel.type.ManagedClass.getManagedProperties(ManagedClass.java:60)
    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:108)
    at org.javers.core.diff.DiffFactory.compare(DiffFactory.java:63)
    at org.javers.core.JaversCore.compare(JaversCore.java:121)
    at org.javers.core.Javers$compare.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
    at ideaGroovyConsole.run(ideaGroovyConsole.groovy:21)
    at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263)
    at groovy.lang.GroovyShell.run(GroovyShell.java:524)
    at groovy.lang.GroovyShell.run(GroovyShell.java:503)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:169)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:71)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
    at console.run(console.txt:25)
    at groovy.ui.GroovyMain.processReader(GroovyMain.java:631)
    at groovy.ui.GroovyMain.processFiles(GroovyMain.java:539)
    at groovy.ui.GroovyMain.run(GroovyMain.java:382)
    at groovy.ui.GroovyMain.process(GroovyMain.java:370)
    at groovy.ui.GroovyMain.processArgs(GroovyMain.java:129)
    at groovy.ui.GroovyMain.main(GroovyMain.java:109)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:109)
    at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:46)
@bartoszwalacik
Copy link
Member

@bartoszwalacik bartoszwalacik commented Jun 9, 2016

please follow Guidelines for Bug Reporting:
Bug Reports have to contain:
...
Runnable test case which isolates the bug and allows us to easily reproduce it on our laptops. You can push this test case to your fork of this repository.

@pranasblk
Copy link
Author

@pranasblk pranasblk commented Jun 10, 2016

To reproduce use Java 8:

package xxx;

public class Payload<T> {
  private T[] pool;

  public Payload(PayloadFactory<T> factory) {
  }

  public interface PayloadFactory<T> {
    T create();
  }
}
package xxx

import org.javers.core.Javers
import org.javers.core.JaversBuilder
import org.javers.core.diff.Diff

Payload<String> o = new Payload({ -> ""})
Javers javers = JaversBuilder.javers().build()
Diff diff = javers.compare(o, o)
println(diff)

Let me know if it is sufficient to reproduce the issue. I like the concept of the project and may put some spare time.

@bartoszwalacik
Copy link
Member

@bartoszwalacik bartoszwalacik commented Jun 10, 2016

Still, cant reproduce. This tests passes in Groovy and Java8

class Somespec extends Specification {

    public class Payload<T> {
        private T[] pool;

        public Payload(PayloadFactory<T> factory) {
        }

        public interface PayloadFactory<T> {
            T create();
        }
    }


    def "should ... "(){
      when:
      Payload<String> o = new Payload({ -> ""})
      Javers javers = JaversBuilder.javers().build()
      Diff diff = javers.compare(o, o)
      println(diff)

      then:
      diff.changes.size() == 0
    }
}

As you can see, there are good reasons why we are asking for a failing and runnable test case

pranasblk added a commit to pranasblk/javers that referenced this issue Jun 10, 2016
@pranasblk
Copy link
Author

@pranasblk pranasblk commented Jun 10, 2016

Test provided #386 (Note: requires Java 8 to reproduce)

pranasblk added a commit to pranasblk/javers that referenced this issue Jun 10, 2016
pranasblk added a commit to pranasblk/javers that referenced this issue Jun 10, 2016
@mwesolowski
Copy link
Member

@mwesolowski mwesolowski commented Jun 11, 2016

Hi @pranasblk, thanks for the test case. Now we can give the issue a closer look. BTW it turns out that this problem doesn't occur if compared objects are compiled in Groovy.

mwesolowski added a commit that referenced this issue Jun 11, 2016
mwesolowski added a commit that referenced this issue Jun 13, 2016
bartoszwalacik added a commit that referenced this issue Jun 14, 2016
#380 generic arrays
@bartoszwalacik
Copy link
Member

@bartoszwalacik bartoszwalacik commented Jun 15, 2016

released in 2.0.1

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

Successfully merging a pull request may close this issue.

None yet
3 participants