[ https://issues.apache.org/jira/browse/DRILL-6349?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16699189#comment-16699189 ]
ASF GitHub Bot commented on DRILL-6349: --------------------------------------- asfgit closed pull request #1446: DRILL-6349: Drill JDBC driver fails on Java 1.9+ with NoClassDefFoundError: sun/misc/VM URL: https://github.com/apache/drill/pull/1446 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/common/src/main/java/org/apache/drill/common/config/DrillConfig.java b/common/src/main/java/org/apache/drill/common/config/DrillConfig.java index 423d4f0e8d1..d7d7340a509 100644 --- a/common/src/main/java/org/apache/drill/common/config/DrillConfig.java +++ b/common/src/main/java/org/apache/drill/common/config/DrillConfig.java @@ -27,6 +27,7 @@ import java.util.Properties; import java.util.concurrent.TimeUnit; +import io.netty.util.internal.PlatformDependent; import org.apache.drill.common.exceptions.DrillConfigurationException; import org.apache.drill.common.exceptions.UserException; import org.apache.drill.common.scanner.ClassPathScanner; @@ -46,7 +47,7 @@ private final ImmutableList<String> startupArguments; @SuppressWarnings("restriction") - private static final long MAX_DIRECT_MEMORY = sun.misc.VM.maxDirectMemory(); + private static final long MAX_DIRECT_MEMORY = PlatformDependent.maxDirectMemory(); @VisibleForTesting public DrillConfig(Config config) { diff --git a/contrib/storage-jdbc/pom.xml b/contrib/storage-jdbc/pom.xml index 7de89f08afe..ad139d467ed 100755 --- a/contrib/storage-jdbc/pom.xml +++ b/contrib/storage-jdbc/pom.xml @@ -104,7 +104,7 @@ <!-- Because the JDBC tests are somewhat heavyweight, we only run them in the 'verify' phase --> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> - <version>2.18.1</version> + <version>2.22.0</version> <configuration> <forkCount combine.self="override">1</forkCount> <systemPropertyVariables> @@ -115,6 +115,7 @@ <includes> <include>**/*IT.java</include> </includes> + <useSystemClassLoader>false</useSystemClassLoader> </configuration> <executions> <execution> diff --git a/distribution/src/resources/drill-config.sh b/distribution/src/resources/drill-config.sh index d23788b006a..8f32a47326c 100644 --- a/distribution/src/resources/drill-config.sh +++ b/distribution/src/resources/drill-config.sh @@ -302,6 +302,17 @@ export DRILLBIT_CODE_CACHE_SIZE=${DRILLBIT_CODE_CACHE_SIZE:-"1G"} export DRILLBIT_OPTS="-Xms$DRILL_HEAP -Xmx$DRILL_HEAP -XX:MaxDirectMemorySize=$DRILL_MAX_DIRECT_MEMORY" export DRILLBIT_OPTS="$DRILLBIT_OPTS -XX:ReservedCodeCacheSize=$DRILLBIT_CODE_CACHE_SIZE -Ddrill.exec.enable-epoll=false" +# Check that java is newer than 1.8 +"$JAVA" -version 2>&1 | grep "version" | egrep -e "1\.8" > /dev/null +if [ $? -gt 0 ]; then + # Allow reflective access on Java 9+ + export DRILLBIT_OPTS="$DRILLBIT_OPTS --add-opens java.base/java.lang=ALL-UNNAMED" + export DRILLBIT_OPTS="$DRILLBIT_OPTS --add-opens java.base/sun.nio.ch=ALL-UNNAMED" + export DRILLBIT_OPTS="$DRILLBIT_OPTS --add-opens java.base/java.nio=ALL-UNNAMED" + export DRILLBIT_OPTS="$DRILLBIT_OPTS --add-opens java.security.jgss/sun.security.krb5=ALL-UNNAMED" + export DRILLBIT_OPTS="$DRILLBIT_OPTS --illegal-access=permit" +fi + # Under YARN, the log directory is usually YARN-provided. Replace any # value that may have been set in drill-env.sh. diff --git a/distribution/src/resources/sqlline.bat b/distribution/src/resources/sqlline.bat index 7821efaecab..40f2771152e 100755 --- a/distribution/src/resources/sqlline.bat +++ b/distribution/src/resources/sqlline.bat @@ -205,6 +205,18 @@ set DRILL_SHELL_JAVA_OPTS=%DRILL_SHELL_JAVA_OPTS% -Dlog.path="%DRILL_LOG_DIR%\sq SET JAVA_CMD=%JAVA_HOME%\bin\%JAVA_EXE% if "%JAVA_HOME%" == "" (set JAVA_CMD=%JAVA_EXE%) set ERROR_CODE=0 + +rem Check that java is newer than 1.8 +"%JAVA_CMD%" -version 2>&1 | findstr "1.8" > nul 2>&1 +if errorlevel 1 ( + rem allow reflective access on Java 9+ + set DRILL_SHELL_JAVA_OPTS=%DRILL_SHELL_JAVA_OPTS% --add-opens java.base/java.lang=ALL-UNNAMED + set DRILL_SHELL_JAVA_OPTS=%DRILL_SHELL_JAVA_OPTS% --add-opens java.base/sun.nio.ch=ALL-UNNAMED + set DRILL_SHELL_JAVA_OPTS=%DRILL_SHELL_JAVA_OPTS% --add-opens java.base/java.nio=ALL-UNNAMED + set DRILL_SHELL_JAVA_OPTS=%DRILL_SHELL_JAVA_OPTS% --add-opens java.security.jgss/sun.security.krb5=ALL-UNNAMED + set DRILL_SHELL_JAVA_OPTS=%DRILL_SHELL_JAVA_OPTS% --illegal-access=permit +) + set SQLLINE_CALL=sqlline.SqlLine -ac org.apache.drill.exec.client.DrillSqlLineApplication -d org.apache.drill.jdbc.Driver if NOT "test%QUERY%"=="test" ( echo %QUERY% | "%JAVA_CMD%" %DRILL_SHELL_JAVA_OPTS% %DRILL_JAVA_OPTS% -cp "%DRILL_CP%" %SQLLINE_CALL% %DRILL_ARGS% diff --git a/exec/java-exec/pom.xml b/exec/java-exec/pom.xml index 43897efd0d7..cbe2285f467 100644 --- a/exec/java-exec/pom.xml +++ b/exec/java-exec/pom.xml @@ -64,16 +64,15 @@ <version>${kerby.version}</version> <scope>test</scope> </dependency> - <!-- <dependency> --> - <!-- <groupId>org.ow2.asm</groupId> --> - <!-- <artifactId>asm-util</artifactId> --> - <!-- <version>5.0.3</version> --> - <!-- </dependency> --> <dependency> <groupId>org.ow2.asm</groupId> - <artifactId>asm-debug-all</artifactId> - <version>5.0.3</version> - <!-- <scope>test</scope> --> + <artifactId>asm-commons</artifactId> + <version>${asm.version}</version> + </dependency> + <dependency> + <groupId>org.ow2.asm</groupId> + <artifactId>asm-util</artifactId> + <version>${asm.version}</version> </dependency> <dependency> <groupId>org.apache.drill.contrib.data</groupId> @@ -81,11 +80,6 @@ <version>${project.version}</version> <scope>test</scope> </dependency> - <!-- <dependency> --> - <!-- <groupId>org.ow2.asm</groupId> --> - <!-- <artifactId>asm-commons</artifactId> --> - <!-- <version>5.0.3</version> --> - <!-- </dependency> --> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-pool2</artifactId> diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/compile/CompilationConfig.java b/exec/java-exec/src/main/java/org/apache/drill/exec/compile/CompilationConfig.java index 7d7180d2c3f..62408132323 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/compile/CompilationConfig.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/compile/CompilationConfig.java @@ -24,5 +24,5 @@ * Never use asm.Opcodes values directly in calls that require them. Use ASM_OPCODES * instead, so that we can change it here once for all references. */ - public final static int ASM_API_VERSION = Opcodes.ASM5; + public final static int ASM_API_VERSION = Opcodes.ASM7; } diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/compile/bytecode/ReplacingInterpreter.java b/exec/java-exec/src/main/java/org/apache/drill/exec/compile/bytecode/ReplacingInterpreter.java index 93828c14b9a..13063c8a5de 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/compile/bytecode/ReplacingInterpreter.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/compile/bytecode/ReplacingInterpreter.java @@ -19,6 +19,7 @@ import java.util.List; +import org.apache.drill.exec.compile.CompilationConfig; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.objectweb.asm.tree.AbstractInsnNode; @@ -40,6 +41,7 @@ private final List<ReplacingBasicValue> valueList; public ReplacingInterpreter(final String className, final List<ReplacingBasicValue> valueList) { + super(CompilationConfig.ASM_API_VERSION); this.className = className; this.valueList = valueList; } diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/ClassGenerator.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/ClassGenerator.java index 5b33acfb602..969b5062bbc 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/ClassGenerator.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/ClassGenerator.java @@ -161,7 +161,7 @@ public static MappingSet getDefaultMapping() { // from the JDK Modifier values to the JCodeModel JMod values: the // values are different. - int mods = JMod.PRIVATE + JMod.FINAL; + int mods = JMod.FINAL; if ((innerClass.getModifiers() & Modifier.STATIC) != 0) { mods += JMod.STATIC; } @@ -370,7 +370,7 @@ private boolean createNestedClass() { // all new fields will be declared in the class from innerClassGenerator if (innerClassGenerator == null) { try { - JDefinedClass innerClazz = clazz._class(JMod.PRIVATE, clazz.name() + "0"); + JDefinedClass innerClazz = clazz._class(JMod.NONE, clazz.name() + "0"); innerClassGenerator = new ClassGenerator<>(codeGenerator, mappings, sig, evaluationVisitor, innerClazz, model, optionManager); } catch (JClassAlreadyExistsException e) { throw new DrillRuntimeException(e); diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/FileSystemPartitionDescriptor.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/FileSystemPartitionDescriptor.java index 2d457015bb3..c38cc5a9ac9 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/FileSystemPartitionDescriptor.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/FileSystemPartitionDescriptor.java @@ -180,7 +180,7 @@ protected void createPartitionSublists() { // build a list of DFSDirPartitionLocation. for (final List<String> dirs : dirToFileMap.keySet()) { - locations.add( new DFSDirPartitionLocation((String [])dirs.toArray(), dirToFileMap.get(dirs))); + locations.add( new DFSDirPartitionLocation(dirs.toArray(new String[dirs.size()]), dirToFileMap.get(dirs))); } locationSuperList = Lists.partition(locations, PartitionDescriptor.PARTITION_BATCH_SIZE); diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestUtf8SupportInQueryString.java b/exec/java-exec/src/test/java/org/apache/drill/TestUtf8SupportInQueryString.java index d6a02f87bd7..523b15b51eb 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/TestUtf8SupportInQueryString.java +++ b/exec/java-exec/src/test/java/org/apache/drill/TestUtf8SupportInQueryString.java @@ -19,19 +19,16 @@ import mockit.Mock; import mockit.MockUp; -import mockit.integration.junit4.JMockit; import org.apache.calcite.util.Util; import org.apache.drill.common.exceptions.UserRemoteException; import org.apache.drill.test.BaseTestQuery; import org.junit.Test; -import org.junit.runner.RunWith; import java.nio.charset.Charset; import static org.hamcrest.CoreMatchers.containsString; import static org.junit.Assert.assertThat; -@RunWith(JMockit.class) public class TestUtf8SupportInQueryString extends BaseTestQuery { @Test diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestCastFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestCastFunctions.java index 7768909c874..37b260c6e61 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestCastFunctions.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestCastFunctions.java @@ -38,17 +38,13 @@ import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; import org.apache.drill.shaded.guava.com.google.common.collect.Lists; import org.apache.drill.shaded.guava.com.google.common.collect.Maps; -import mockit.integration.junit4.JMockit; - import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.hasItem; -@RunWith(JMockit.class) @Category({UnlikelyTest.class, SqlFunctionTest.class}) public class TestCastFunctions extends BaseTestQuery { diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestDateFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestDateFunctions.java index d61c729fc95..8c4bf8e12e9 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestDateFunctions.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestDateFunctions.java @@ -19,7 +19,6 @@ import org.apache.drill.shaded.guava.com.google.common.base.Charsets; import org.apache.drill.shaded.guava.com.google.common.io.Files; -import mockit.integration.junit4.JMockit; import org.apache.drill.categories.SqlFunctionTest; import org.apache.drill.categories.UnlikelyTest; import org.apache.drill.common.util.DrillFileUtils; @@ -37,12 +36,10 @@ import org.junit.Ignore; import org.junit.Test; import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -@RunWith(JMockit.class) @Category({UnlikelyTest.class, SqlFunctionTest.class}) public class TestDateFunctions extends PopUnitTestBase { diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/testing/TestDateConversions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/testing/TestDateConversions.java index e0121e6c186..363d326b4ab 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/testing/TestDateConversions.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/testing/TestDateConversions.java @@ -17,7 +17,6 @@ */ package org.apache.drill.exec.fn.impl.testing; -import mockit.integration.junit4.JMockit; import org.apache.drill.test.BaseTestQuery; import org.apache.drill.categories.SqlFunctionTest; import org.apache.drill.categories.UnlikelyTest; @@ -25,7 +24,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; @@ -37,7 +35,6 @@ import static org.hamcrest.CoreMatchers.startsWith; import static org.junit.Assert.assertThat; -@RunWith(JMockit.class) @Category({UnlikelyTest.class, SqlFunctionTest.class}) public class TestDateConversions extends BaseTestQuery { diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/interp/TestConstantFolding.java b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/interp/TestConstantFolding.java index c1fea16c3a3..879dc4b3461 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/interp/TestConstantFolding.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/interp/TestConstantFolding.java @@ -19,19 +19,16 @@ import org.apache.drill.shaded.guava.com.google.common.base.Joiner; import org.apache.drill.shaded.guava.com.google.common.collect.Lists; -import mockit.integration.junit4.JMockit; import org.apache.drill.PlanTestBase; import org.apache.drill.categories.SqlTest; import org.apache.drill.exec.planner.physical.PlannerSettings; import org.junit.Ignore; import org.junit.Test; import org.junit.experimental.categories.Category; -import org.junit.runner.RunWith; import java.io.File; import java.io.PrintWriter; import java.util.List; -@RunWith(JMockit.class) @Category(SqlTest.class) public class TestConstantFolding extends PlanTestBase { diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/impersonation/TestImpersonationMetadata.java b/exec/java-exec/src/test/java/org/apache/drill/exec/impersonation/TestImpersonationMetadata.java index 9acd0154505..6dc361549c1 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/impersonation/TestImpersonationMetadata.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/impersonation/TestImpersonationMetadata.java @@ -280,7 +280,7 @@ public void testCreateViewInWSWithNoPermissionsForQueryUser() throws Exception { final String query = "CREATE VIEW " + viewName + " AS SELECT " + "c_custkey, c_nationkey FROM cp.`tpch/customer.parquet` ORDER BY c_custkey;"; - final String expErrorMsg = "PERMISSION ERROR: Permission denied: user=drillTestUser2, access=WRITE, inode=\"/drill_test_grp_0_755/"; + final String expErrorMsg = "PERMISSION ERROR: Permission denied: user=drillTestUser2, access=WRITE, inode=\"/drill_test_grp_0_755"; errorMsgTestHelper(query, expErrorMsg); // SHOW TABLES is expected to return no records as view creation fails above. @@ -351,7 +351,7 @@ public void testCreateTableInWSWithNoPermissionsForQueryUser() throws Exception thrown.expect(UserRemoteException.class); thrown.expectMessage(containsString("Permission denied: user=drillTestUser2, " + - "access=WRITE, inode=\"/drill_test_grp_0_755/")); + "access=WRITE, inode=\"/drill_test_grp_0_755")); test("CREATE TABLE %s AS SELECT c_custkey, c_nationkey " + "FROM cp.`tpch/customer.parquet` ORDER BY c_custkey", tableName); diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/avro/AvroFormatTest.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/avro/AvroFormatTest.java index 2b7edc93b64..8f2339b70fc 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/avro/AvroFormatTest.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/avro/AvroFormatTest.java @@ -56,16 +56,12 @@ import org.apache.drill.test.TestBuilder; import org.junit.Assert; import org.junit.Test; -import org.junit.runner.RunWith; import org.apache.drill.shaded.guava.com.google.common.collect.Lists; -import mockit.integration.junit4.JMockit; - /** * Unit tests for Avro record reader. */ -@RunWith(JMockit.class) public class AvroFormatTest extends BaseTestQuery { // XXX diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/vector/complex/writer/TestExtendedTypes.java b/exec/java-exec/src/test/java/org/apache/drill/exec/vector/complex/writer/TestExtendedTypes.java index c2d3f9aa01e..bc27e880445 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/vector/complex/writer/TestExtendedTypes.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/vector/complex/writer/TestExtendedTypes.java @@ -17,7 +17,6 @@ */ package org.apache.drill.exec.vector.complex.writer; -import mockit.integration.junit4.JMockit; import static org.junit.Assert.assertEquals; import java.nio.file.Files; @@ -30,9 +29,7 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; -import org.junit.runner.RunWith; -@RunWith(JMockit.class) public class TestExtendedTypes extends BaseTestQuery { @BeforeClass public static void setupTestFiles() { diff --git a/exec/java-exec/src/test/resources/drill-udf/pom.xml b/exec/java-exec/src/test/resources/drill-udf/pom.xml index 73618451b2b..931abedb207 100644 --- a/exec/java-exec/src/test/resources/drill-udf/pom.xml +++ b/exec/java-exec/src/test/resources/drill-udf/pom.xml @@ -63,12 +63,14 @@ <includes> <include>${include.files}</include> </includes> + <source>1.8</source> + <target>1.8</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> - <version>2.4</version> + <version>3.0.1</version> <configuration> <finalName>${jar.finalName}</finalName> <includes> diff --git a/exec/jdbc-all/pom.xml b/exec/jdbc-all/pom.xml index 7be43ab29bf..e0ae482b15b 100644 --- a/exec/jdbc-all/pom.xml +++ b/exec/jdbc-all/pom.xml @@ -241,7 +241,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> - <version>2.18.1</version> + <version>2.22.0</version> <executions> <execution> <goals> @@ -268,6 +268,7 @@ <app.class.path>${app.class.path}</app.class.path> <project.version>${project.version}</project.version> </systemPropertyVariables> + <useSystemClassLoader>false</useSystemClassLoader> </configuration> </plugin> @@ -333,6 +334,7 @@ <exclude>commons-beanutils:commons-beanutils-core:jar:*</exclude> <exclude>commons-beanutils:commons-beanutils:jar:*</exclude> <exclude>io.netty:netty-tcnative:jar:*</exclude> + <exclude>org.honton.chas.hocon:jackson-dataformat-hocon:*</exclude> </excludes> </artifactSet> <relocations> @@ -648,6 +650,7 @@ <exclude>commons-io:commons-io</exclude> <exclude>commons-beanutils:commons-beanutils-core:jar:*</exclude> <exclude>commons-beanutils:commons-beanutils:jar:*</exclude> + <exclude>org.honton.chas.hocon:jackson-dataformat-hocon:*</exclude> </excludes> </artifactSet> <relocations> diff --git a/exec/jdbc-all/src/test/java/org/apache/drill/jdbc/ITTestShadedJar.java b/exec/jdbc-all/src/test/java/org/apache/drill/jdbc/ITTestShadedJar.java index 6319cb32e4d..4fed1464358 100644 --- a/exec/jdbc-all/src/test/java/org/apache/drill/jdbc/ITTestShadedJar.java +++ b/exec/jdbc-all/src/test/java/org/apache/drill/jdbc/ITTestShadedJar.java @@ -42,7 +42,7 @@ private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ITTestShadedJar.class); private static DrillbitClassLoader drillbitLoader; - private static URLClassLoader rootClassLoader; + private static ClassLoader rootClassLoader; private static int userPort; @ClassRule @@ -55,7 +55,7 @@ protected void starting(Description description) { try { drillbitLoader = new DrillbitClassLoader(); drillbitLoader.loadClass("org.apache.commons.io.FileUtils"); - rootClassLoader = (URLClassLoader) Thread.currentThread().getContextClassLoader(); + rootClassLoader = Thread.currentThread().getContextClassLoader(); Class<?> clazz = drillbitLoader.loadClass("org.apache.drill.test.BaseTestQuery"); Class<?> watcherClazz = drillbitLoader.loadClass("org.apache.drill.test.BaseDirTestWatcher"); @@ -134,10 +134,7 @@ private static URL getJdbcUrl() throws MalformedURLException { @Test public void testDatabaseVersion() throws Exception { - final URLClassLoader loader = (URLClassLoader) ClassLoader.getSystemClassLoader(); - Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); - method.setAccessible(true); - method.invoke(loader, getJdbcUrl()); + final URLClassLoader loader = URLClassLoader.newInstance(new URL[] {getJdbcUrl()}); Class<?> clazz = loader.loadClass("org.apache.drill.jdbc.Driver"); try { @@ -155,10 +152,7 @@ public void testDatabaseVersion() throws Exception { @Test public void executeJdbcAllQuery() throws Exception { - final URLClassLoader loader = (URLClassLoader) ClassLoader.getSystemClassLoader(); - Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); - method.setAccessible(true); - method.invoke(loader, getJdbcUrl()); + final URLClassLoader loader = URLClassLoader.newInstance(new URL[] {getJdbcUrl()}); Class<?> clazz = loader.loadClass("org.apache.drill.jdbc.Driver"); try { diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java index 303565fa839..b868cf593ff 100644 --- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java +++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java @@ -41,6 +41,7 @@ import java.sql.ResultSetMetaData; import java.sql.SQLClientInfoException; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; import java.sql.Statement; import java.util.ArrayList; import java.util.List; @@ -412,6 +413,15 @@ public String getReport() { super(intf, jdbcObject, STATEMENT_CLOSED_MESSAGE); } + @Override + protected boolean isOkayNonthrowingMethod(Method method) { + return + super.isOkayNonthrowingMethod(method) + // New Java 9 methods not implemented in Avatica. + || method.getName().equals("beginRequest") + || method.getName().equals("endRequest"); + } + @Override protected boolean isOkaySpecialCaseException(Method method, Throwable cause) { final boolean result; @@ -424,6 +434,12 @@ else if (SQLClientInfoException.class == cause.getClass() || method.getName().equals("getClientInfo"))) { // Special good case--we had to use SQLClientInfoException from those. result = true; + } + else if (SQLFeatureNotSupportedException.class == cause.getClass() + && (method.getName().equals("setShardingKeyIfValid") + || method.getName().equals("setShardingKey"))) { + // New Java 9 methods not implemented in Avatica. + result = true; } else { result = false; } @@ -453,6 +469,24 @@ public void testClosedConnectionMethodsThrowRight() { ClosedPlainStatementChecker(Class<Statement> intf, Statement jdbcObject) { super(intf, jdbcObject, PLAIN_STATEMENT_CLOSED_MESSAGE); } + + @Override + protected boolean isOkaySpecialCaseException(Method method, Throwable cause) { + final boolean result; + if (super.isOkaySpecialCaseException(method, cause)) { + result = true; + } else if (NullPointerException.class == cause.getClass() + && (method.getName().equals("enquoteIdentifier") + || method.getName().equals("enquoteLiteral") + || method.getName().equals("enquoteNCharLiteral") + || method.getName().equals("isSimpleIdentifier"))) { + result = true; + } else { + result = false; + } + + return result; + } } // class ClosedPlainStatementChecker @Test @@ -477,6 +511,24 @@ public void testClosedPlainStatementMethodsThrowRight() { PreparedStatement jdbcObject) { super(intf, jdbcObject, PREPAREDSTATEMENT_CLOSED_MESSAGE); } + + @Override + protected boolean isOkaySpecialCaseException(Method method, Throwable cause) { + final boolean result; + if (super.isOkaySpecialCaseException(method, cause)) { + result = true; + } else if (NullPointerException.class == cause.getClass() + && (method.getName().equals("enquoteIdentifier") + || method.getName().equals("enquoteLiteral") + || method.getName().equals("enquoteNCharLiteral") + || method.getName().equals("isSimpleIdentifier"))) { + result = true; + } else { + result = false; + } + + return result; + } } // class closedPreparedStmtOfOpenConnChecker @Test @@ -587,7 +639,9 @@ protected boolean isOkayNonthrowingMethod(Method method) { || method.getName().equals("getConnection") // TODO: New Java 8 methods not implemented in Avatica. || method.getName().equals("getMaxLogicalLobSize") - || method.getName().equals("supportsRefCursors"); + || method.getName().equals("supportsRefCursors") + // New Java 9 methods not implemented in Avatica. + || method.getName().equals("supportsSharding"); } @Override diff --git a/exec/memory/base/src/test/java/org/apache/drill/exec/memory/BoundsCheckingTest.java b/exec/memory/base/src/test/java/org/apache/drill/exec/memory/BoundsCheckingTest.java index 5d2853bcc40..80212281366 100644 --- a/exec/memory/base/src/test/java/org/apache/drill/exec/memory/BoundsCheckingTest.java +++ b/exec/memory/base/src/test/java/org/apache/drill/exec/memory/BoundsCheckingTest.java @@ -46,6 +46,7 @@ private static boolean setBoundsChecking(boolean enabled) throws Exception modifiersField.setAccessible(true); modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); boolean old = field.getBoolean(null); + field.setAccessible(true); field.set(null, enabled); return old; } diff --git a/logical/pom.xml b/logical/pom.xml index ed9abb768e6..aa8fb067c83 100644 --- a/logical/pom.xml +++ b/logical/pom.xml @@ -105,7 +105,6 @@ </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> - <version>2.15</version> <configuration> <useSystemClassLoader>false</useSystemClassLoader> </configuration> diff --git a/pom.xml b/pom.xml index d69c67993b9..0cc25279f77 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ <maven.embedder.version>3.5.3</maven.embedder.version> <curator.version>2.7.1</curator.version> <wiremock.standalone.version>2.5.1</wiremock.standalone.version> - <jmockit.version>1.39</jmockit.version> + <jmockit.version>1.43</jmockit.version> <logback.version>1.0.13</logback.version> <mockito.version>2.18.3</mockito.version> <!-- @@ -72,15 +72,16 @@ Apache Hive 2.3.2. If the version is changed, make sure the jars and their dependencies are updated. --> <hive.version>2.3.2</hive.version> - <hadoop.version>2.7.1</hadoop.version> - <hbase.version>1.1.3</hbase.version> + <hadoop.version>2.7.4</hadoop.version> + <hbase.version>2.1.0</hbase.version> <fmpp.version>1.0</fmpp.version> <freemarker.version>2.3.26-incubating</freemarker.version> - <javassist.version>3.22.0-GA</javassist.version> + <javassist.version>3.24.0-GA</javassist.version> <msgpack.version>0.6.6</msgpack.version> <reflections.version>0.9.10</reflections.version> <avro.version>1.8.2</avro.version> <metrics.version>4.0.2</metrics.version> + <asm.version>7.0</asm.version> <excludedGroups /> <memoryMb>4096</memoryMb> <directMemoryMb>4096</directMemoryMb> @@ -492,7 +493,7 @@ <version>[3.3.1,4)</version> </requireMavenVersion> <requireJavaVersion> - <version>[1.8,1.9)</version> + <version>[1.8,12)</version> </requireJavaVersion> </rules> </configuration> @@ -681,11 +682,11 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>3.2</version> + <version>3.8.0</version> </plugin> <plugin> <artifactId>maven-enforcer-plugin</artifactId> - <version>1.3.1</version> + <version>3.0.0-M1</version> </plugin> <plugin> <!-- classpath scanning --> <groupId>org.codehaus.mojo</groupId> @@ -710,7 +711,7 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.17</version> + <version>2.21.0</version> <executions> <execution> <id>default-test</id> @@ -722,7 +723,7 @@ <dependency> <groupId>org.apache.maven.surefire</groupId> <artifactId>surefire-junit47</artifactId> - <version>2.19.1</version> + <version>2.21.0</version> </dependency> </dependencies> <configuration> @@ -735,6 +736,8 @@ -Djava.net.preferIPv4Stack=true -Djava.awt.headless=true -XX:+CMSClassUnloadingEnabled -ea + -Djdk.attach.allowAttachSelf=true + -javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar </argLine> <forkCount>${forkCount}</forkCount> <reuseForks>true</reuseForks> @@ -745,6 +748,7 @@ <java.io.tmpdir>${project.build.directory}</java.io.tmpdir> </systemPropertyVariables> <excludedGroups>${excludedGroups}</excludedGroups> + <useSystemClassLoader>false</useSystemClassLoader> </configuration> </plugin> <plugin> @@ -925,7 +929,7 @@ <!-- JMockit needs to be on class path before JUnit. --> <groupId>org.jmockit</groupId> <artifactId>jmockit</artifactId> - <version>1.39</version> + <version>${jmockit.version}</version> <scope>test</scope> </dependency> <dependency> ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Drill JDBC driver fails on Java 1.9+ with NoClassDefFoundError: sun/misc/VM > --------------------------------------------------------------------------- > > Key: DRILL-6349 > URL: https://issues.apache.org/jira/browse/DRILL-6349 > Project: Apache Drill > Issue Type: Bug > Components: Client - JDBC > Affects Versions: 1.13.0 > Environment: 16:23 apache-drill-1.13.0$ uname -a > Darwin bix.local 17.5.0 Darwin Kernel Version 17.5.0: Mon Mar 5 22:24:32 PST > 2018; root:xnu-4570.51.1~1/RELEASE_X86_64 x86_64 > > Reporter: Marc Prud'hommeaux > Assignee: Oleg Zinoviev > Priority: Major > Labels: ready-to-commit > Fix For: 1.15.0 > > > I'm surprised to be unable to find this issue logged elsewhere, but a quick > search yields nothing. Trying to connect with the JDBC driver raises a > NoClassDefFoundError for sun.misc.VM, which was removed in Java 9. It is > understandable that the full drillbit (or its many dependencies) may have > difficult-to-extract dependencies on some sun.misc.* classes, but the JDBC > driver should be able to be loaded by any JVM. > > Looking at > ./common/src/main/java/org/apache/drill/common/config/DrillConfig.java, it > appears that a quick workaround could be to make sun.misc.VM.maxDirectMemory > called lazily from the one place that uses it: getMaxDirectMemory() > > > > {{}}{{16:21 apache-drill-1.13.0$ > JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk > ./bin/drill-localhost }} > ***Connecting to jdbc:drill:drillbit=localhost* > WARNING: An illegal reflective access operation has occurred > WARNING: Illegal reflective access by > org.apache.calcite.avatica.com.google.protobuf.UnsafeUtil > (file:/Users/marc/Downloads/apache-drill-1.13.0/jars/3rdparty/avatica-1.10.0.jar) > to field java.nio.Buffer.address > WARNING: Please consider reporting this to the maintainers of > org.apache.calcite.avatica.com.google.protobuf.UnsafeUtil > WARNING: Use --illegal-access=warn to enable warnings of further illegal > reflective access operations > WARNING: All illegal access operations will be denied in a future release > {{java.lang.NoClassDefFoundError: sun/misc/VM}} > {{ at > org.apache.drill.common.config.DrillConfig.<clinit>(DrillConfig.java:49)}} > {{ at > org.apache.drill.jdbc.impl.DrillConnectionImpl.<init>(DrillConnectionImpl.java:155)}} > {{ at > org.apache.drill.jdbc.impl.DrillJdbc41Factory.newDrillConnection(DrillJdbc41Factory.java:73)}} > {{ at > org.apache.drill.jdbc.impl.DrillFactory.newConnection(DrillFactory.java:69)}} > {{ at > org.apache.calcite.avatica.UnregisteredDriver.connect(UnregisteredDriver.java:138)}} > {{ at org.apache.drill.jdbc.Driver.connect(Driver.java:72)}} > {{ at sqlline.DatabaseConnection.connect(DatabaseConnection.java:168)}} > {{ at sqlline.DatabaseConnection.getConnection(DatabaseConnection.java:214)}} > {{ at sqlline.Commands.connect(Commands.java:1083)}} > {{ at sqlline.Commands.connect(Commands.java:1015)}} > {{ at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native > Method)}} > {{ at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)}} > {{ at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)}} > {{ at java.base/java.lang.reflect.Method.invoke(Method.java:564)}} > {{ at > sqlline.ReflectiveCommandHandler.execute(ReflectiveCommandHandler.java:36)}} > {{ at sqlline.SqlLine.dispatch(SqlLine.java:742)}} > {{ at sqlline.SqlLine.initArgs(SqlLine.java:528)}} > {{ at sqlline.SqlLine.begin(SqlLine.java:596)}} > {{ at sqlline.SqlLine.start(SqlLine.java:375)}} > {{ at sqlline.SqlLine.main(SqlLine.java:268)}} > {{Caused by: java.lang.ClassNotFoundException: sun.misc.VM}} > {{ at > java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)}} > {{ at > java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)}} > {{ at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)}} > {{... 20 more}} > apache drill 1.13.0 > "just drill it" > 0: jdbc:drill:drillbit=localhost> > -- This message was sent by Atlassian JIRA (v7.6.3#76005)