Skip to content

Commit

Permalink
Add jdk internal package for mocking (#79715)
Browse files Browse the repository at this point in the history
When mocking some jdk classes, the jdk.internal package must be
accessible to mockito. This commit adds the needed permission so classes
like ZoneId can be mocked. closes #79704
  • Loading branch information
rjernst authored Oct 25, 2021
1 parent 809c13f commit ebb1d3a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
grant codeBase "${codebase.mockito-core}" {
// needed to access ReflectionFactory (see below)
permission java.lang.RuntimePermission "accessClassInPackage.sun.reflect";
permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal";
// needed for reflection in ibm jdk
permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
// needed to support creation of mocks
Expand All @@ -29,6 +30,7 @@ grant codeBase "${codebase.byte-buddy}" {
permission java.lang.RuntimePermission "accessDeclaredMembers";
permission java.lang.RuntimePermission "net.bytebuddy.createJavaDispatcher";
permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
permission java.lang.reflect.ReflectPermission "newProxyInPackage.net.bytebuddy.utility";
permission java.lang.reflect.ReflectPermission "newProxyInPackage.net.bytebuddy.dynamic.loading";
Expand All @@ -39,6 +41,7 @@ grant codeBase "${codebase.byte-buddy}" {
grant codeBase "${codebase.objenesis}" {
permission java.lang.RuntimePermission "reflectionFactoryAccess";
permission java.lang.RuntimePermission "accessClassInPackage.sun.reflect";
permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal";
permission java.lang.RuntimePermission "accessDeclaredMembers";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;

import org.apache.lucene.util.LuceneTestCase.AwaitsFix;
import org.elasticsearch.common.Strings;
import org.elasticsearch.core.PathUtils;
import org.elasticsearch.core.SuppressForbidden;
Expand Down Expand Up @@ -89,7 +88,6 @@
* node of that type is called for.
* </ul>
*/
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/79704")
public class NodeSubclassTests<T extends B, B extends Node<B>> extends ESTestCase {

private static final List<Class<?>> CLASSES_WITH_MIN_TWO_CHILDREN = asList(In.class, InPipe.class);
Expand Down

0 comments on commit ebb1d3a

Please sign in to comment.