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

Fix failing unit tests #4

Open
martinjoconnor opened this issue Nov 14, 2023 · 1 comment
Open

Fix failing unit tests #4

martinjoconnor opened this issue Nov 14, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@martinjoconnor
Copy link
Member

Some unit tests fail, e.g.,

13:41:11.767 [main] DEBUG org.eclipse.jetty.util.log - Logging to Logger[org.eclipse.jetty.util.log] via org.eclipse.jetty.util.log.Slf4jLog
13:41:11.768 [main] INFO org.eclipse.jetty.util.log - Logging initialized @418ms to org.eclipse.jetty.util.log.Slf4jLog
13:41:11.799 [main] DEBUG org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl - Adding composing constraint: ConstraintDescriptorImpl{annotation=javax.validation.constraints.NotNull, payloads=[], hasComposingConstraints=true, isReportAsSingleInvalidConstraint=false, elementType=FIELD, definedOn=DEFINED_LOCALLY, groups=[interface javax.validation.groups.Default], attributes={message={javax.validation.constraints.NotNull.message}, payload=[Ljava.lang.Class;@7728643a, groups=[Ljava.lang.Class;@320e400}, constraintType=GENERIC}.
13:41:11.799 [main] DEBUG org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl - Adding composing constraint: ConstraintDescriptorImpl{annotation=javax.validation.constraints.Size, payloads=[], hasComposingConstraints=true, isReportAsSingleInvalidConstraint=false, elementType=FIELD, definedOn=DEFINED_LOCALLY, groups=[interface javax.validation.groups.Default], attributes={groups=[Ljava.lang.Class;@28c0b664, min=1, message={javax.validation.constraints.Size.message}, payload=[Ljava.lang.Class;@2c444798, max=2147483647}, constraintType=GENERIC}.
13:41:11.799 [main] DEBUG org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl - Adding composing constraint: ConstraintDescriptorImpl{annotation=javax.validation.constraints.NotNull, payloads=[], hasComposingConstraints=true, isReportAsSingleInvalidConstraint=false, elementType=FIELD, definedOn=DEFINED_LOCALLY, groups=[interface javax.validation.groups.Default], attributes={message={javax.validation.constraints.NotNull.message}, payload=[Ljava.lang.Class;@68ed96ca, groups=[Ljava.lang.Class;@6d1310f6}, constraintType=GENERIC}.
13:41:11.800 [main] DEBUG org.hibernate.validator.internal.metadata.descriptor.ConstraintDescriptorImpl - Adding composing constraint: ConstraintDescriptorImpl{annotation=javax.validation.constraints.Size, payloads=[], hasComposingConstraints=true, isReportAsSingleInvalidConstraint=false, elementType=FIELD, definedOn=DEFINED_LOCALLY, groups=[interface javax.validation.groups.Default], attributes={groups=[Ljava.lang.Class;@3228d990, min=1, message={javax.validation.constraints.Size.message}, payload=[Ljava.lang.Class;@54e7391d, max=2147483647}, constraintType=GENERIC}.
java.lang.reflect.InaccessibleObjectException: Unable to make field private static final java.util.HashMap java.lang.ProcessEnvironment.theEnvironment accessible: module java.base does not "opens java.lang" to unnamed module @60d14f0f
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)

@martinjoconnor martinjoconnor added the bug Something isn't working label Nov 14, 2023
@egyedia
Copy link
Member

egyedia commented Nov 15, 2023

The problem is this block:

      Class<?> processEnvironmentClass = Class.forName("java.lang.ProcessEnvironment");
      Field theEnvironmentField = processEnvironmentClass.getDeclaredField("theEnvironment");
      theEnvironmentField.setAccessible(true);

From Java9 this contradicts the module system restrictions.
One way around this would be to upgrade to JUnit5, and use one of the solutions mentioned here:
http://stackoverflow.com/questions/318239/how-do-i-set-environment-variables-from-java

Upgrading to JUnit5 might be a considerable amount of work, although there are migration tools in IntelliJ Idea that can help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants