Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-18181

Fix tests post JDK-8210522 (rewrite reflection of "modifiers" field)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • 5.0-alpha1, 5.0
    • CI
    • None

    Description

       

      From JDK-8210522:

      Core reflection has a filtering mechanism to hide security and integrity sensitive fields and methods from Class getXXXField(s) and getXXXMethod(s). The filtering mechanism has been used for several releases to hide security sensitive fields such as System.security and Class.classLoader.
      This CSR proposes to extend the filters to hide fields from a number of highly security sensitive classes in java.lang.reflect and java.lang.invoke.
      

      We are using at a few places in our tests 

      Field.class.getDeclaredField("modifiers");

      This breaks as expected when tests are run with JDK17, example:
       

      java.lang.RuntimeException: java.lang.NoSuchFieldException: modifiers
       at org.apache.cassandra.transport.MessagePayloadTest.makeCqlQueryHandlerAccessible(MessagePayloadTest.java:79)
       at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
       at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.base/java.lang.reflect.Method.invoke(Method.java:568)
       at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
       at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
       at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
       at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
       at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
       at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
       at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
       at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
       at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:221)
       at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54) 
      Caused by: java.lang.NoSuchFieldException: modifiers at java.base/java.lang.Class.getDeclaredField(Class.java:2610) 
      at org.apache.cassandra.transport.MessagePayloadTest.makeCqlQueryHandlerAccessible(MessagePayloadTest.java:70) 
      ... 15 more

       

      Attachments

        Issue Links

          Activity

            People

              e.dimitrova Ekaterina Dimitrova
              e.dimitrova Ekaterina Dimitrova
              Ekaterina Dimitrova
              Michael Semb Wever
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: