-
Notifications
You must be signed in to change notification settings - Fork 4.2k
ARROW-17604: [Docs][Java] Make it more obvious that --add-opens is required #14066
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,4 +37,58 @@ | |
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-surefire-plugin</artifactId> | ||
|
|
||
| <configuration> | ||
| <excludes> | ||
| <!-- Test is only useful when NOT running with add-opens --> | ||
| <exclude>**/TestOpens.java</exclude> | ||
| </excludes> | ||
| </configuration> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
|
|
||
| <profiles> | ||
| <profile> | ||
| <id>opens-tests</id> | ||
| <!-- Run tests WITHOUT add-opens to make sure we fail-fast --> | ||
| <activation> | ||
| <jdk>[16,]</jdk> | ||
| </activation> | ||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-surefire-plugin</artifactId> | ||
|
|
||
| <executions> | ||
| <execution> | ||
| <id>opens-tests</id> | ||
| <phase>test</phase> | ||
| <goals> | ||
| <goal>test</goal> | ||
| </goals> | ||
| <configuration> | ||
| <!-- Dummy value to stop inheriting the default add-opens flag --> | ||
| <argLine>-Dfoo=bar</argLine> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could suggest that this line add more arg configuration instead of reset inheriting .values...
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean parent project configure When you run the TestOpens test it's throw the exception? |
||
| <excludes> | ||
| <!-- Need something (anything) here to make Maven not inherit the value above --> | ||
| <exclude>**/TestArrowBuf.java</exclude> | ||
| </excludes> | ||
| <includes> | ||
| <include>**/TestOpens.java</include> | ||
| </includes> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </profile> | ||
| </profiles> | ||
| </project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.arrow.memory; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
| import org.junit.Test; | ||
|
|
||
| public class TestOpens { | ||
| /** Instantiating the RootAllocator should poke MemoryUtil and fail. */ | ||
| @Test | ||
| public void testMemoryUtilFailsLoudly() { | ||
| // This test is configured by Maven to run WITHOUT add-opens. So this should fail on JDK16+ | ||
| // (where JEP396 means that add-opens is required to access JDK internals). | ||
| // The test will likely fail in your IDE if it doesn't correctly pick this up. | ||
| Throwable e = assertThrows(Throwable.class, () -> { | ||
| BufferAllocator allocator = new RootAllocator(); | ||
| allocator.close(); | ||
| }); | ||
| boolean found = false; | ||
| while (e != null) { | ||
| e = e.getCause(); | ||
| if (e instanceof RuntimeException && e.getMessage().contains("Failed to initialize MemoryUtil")) { | ||
| found = true; | ||
| break; | ||
| } | ||
| } | ||
| assertTrue(found, "Expected exception as not thrown"); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to get the TestOpens exception with JRE18 but if finished without that error, Is there some additional configuration needed? Probably
mvn -Dtest="TestOpens" clean testnot thrown that exception because for test this inherit parent configuration.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works with just
mvn test. I presume specifying the test name manually is causing it to bypass this configuration.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, that was the case