Uploaded image for project: 'Hibernate Search'
  1. HSEARCH-2697

Mapping with @Field @IndexedEmbedded Integer[] field throws InaccessibleObjectException

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.8.0.Beta1
    • Fix Version/s: 5.8.0.Beta2
    • Component/s: mapper-pojo
    • Labels:
      None
    • Environment:
      JDK 9

      Description

      When we find an @IndexedEmbedded, we use introspection to find out exactly what is "embedded". This makes sense, since @IndexedEmbedded is about embedding stuff, right?
      Well, not always. The @IndexedEmbedded annotation has another meaning: when there is a @Field on the annotated property, we actually use it to tell Hibernate Search to wrap the field bridge in a "container" field bridge (see HSEARCH-2554 Closed ). This is especially useful when one wants to index a list or array of simple values, such as String or Integer for instance.
      Since we cannot distinguish between the two use cases, we end up always using introspection on the element type, even if the element type is something like java.lang.Integer.

      This is fine in JDK8 and below, but starting from JDK9 such things are prevented by module isolation: you can't use setAccessible outside of your own module unless explicitly allowed to, and thus you can't inspect private members by default.

      Stack trace:

      Tests run: 12, Failures: 0, Errors: 12, Skipped: 0, Time elapsed: 0.169 sec <<< FAILURE! - in org.hibernate.search.test.sorting.SortingTest
      testSortingOnNumericInt(org.hibernate.search.test.sorting.SortingTest)  Time elapsed: 0.053 sec  <<< ERROR!
      java.lang.reflect.InaccessibleObjectException: Unable to make field private final int java.lang.Integer.value accessible: module java.base does not "opens java.lang" to unnamed module @7d1f3fe9
      	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:335)
      	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:278)
      	at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:175)
      	at java.base/java.lang.reflect.Field.setAccessible(Field.java:169)
      	at org.hibernate.annotations.common.reflection.java.JavaXMember.setAccessible(JavaXMember.java:121)
      	at org.hibernate.search.util.impl.ReflectionHelper.setAccessible(ReflectionHelper.java:59)
      	at org.hibernate.search.engine.metadata.impl.PropertyMetadata$Builder.<init>(PropertyMetadata.java:129)
      	at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeMemberLevelAnnotations(AnnotationMetadataProvider.java:1022)
      	at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeClass(AnnotationMetadataProvider.java:600)
      	at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.checkForIndexedEmbedded(AnnotationMetadataProvider.java:1847)
      	at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeMemberLevelAnnotations(AnnotationMetadataProvider.java:1040)
      	at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeClass(AnnotationMetadataProvider.java:600)
      	at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.doGetTypeMetadataFor(AnnotationMetadataProvider.java:174)
      	at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.getTypeMetadataFor(AnnotationMetadataProvider.java:164)
      	at org.hibernate.search.spi.SearchIntegratorBuilder.initDocumentBuilders(SearchIntegratorBuilder.java:441)
      	at org.hibernate.search.spi.SearchIntegratorBuilder.createNewFactoryState(SearchIntegratorBuilder.java:237)
      	at org.hibernate.search.spi.SearchIntegratorBuilder.buildNewSearchFactory(SearchIntegratorBuilder.java:193)
      	at org.hibernate.search.spi.SearchIntegratorBuilder.buildSearchIntegrator(SearchIntegratorBuilder.java:122)
      	at org.hibernate.search.testsupport.junit.SearchFactoryHolder.createSearchFactory(SearchFactoryHolder.java:92)
      	at org.hibernate.search.testsupport.junit.SearchFactoryHolder.before(SearchFactoryHolder.java:73)
      	at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:46)
      	at org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
      	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:283)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:173)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
      	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:128)
      	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
      	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
      	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
      

        Attachments

          Activity

            People

            • Assignee:
              yrodiere Yoann Rodière
              Reporter:
              yrodiere Yoann Rodière
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: