Chaho12 commented on code in PR #5809: URL: https://github.com/apache/hive/pull/5809#discussion_r2262122299
########## common/src/java/org/apache/hadoop/hive/common/JavaVersionUtils.java: ########## @@ -0,0 +1,66 @@ +/* + * 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.hadoop.hive.common; + +public class JavaVersionUtils { + private JavaVersionUtils() { + throw new IllegalStateException("Utility class"); + } + + /** + * Returns the detected Java major version (e.g., 8, 11, 17). + */ + public static int getJavaMajorVersion() { + return Math.max(8, Integer.parseInt( + System.getProperty("java.specification.version").split("\\.")[0])); + } + + /** + * Returns the full --add-opens string if Java 9, or an empty string if Java 8 or below. + */ + public static String getAddOpensFlagsIfNeeded() { + //TODO: Please remove this once the codebase has been migrated to JDK 9 or a higher version. + int javaVersion = getJavaMajorVersion(); + if (javaVersion >= 9) { + return " --add-opens=java.base/java.net=ALL-UNNAMED" + + " --add-opens=java.base/java.util=ALL-UNNAMED" + + " --add-opens=java.base/java.util.concurrent=ALL-UNNAMED" + + " --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED" + + " --add-opens=java.base/java.lang=ALL-UNNAMED" + + " --add-opens=java.base/java.io=ALL-UNNAMED" + + " --add-opens java.base/java.lang=ALL-UNNAMED" + Review Comment: missing `=` after --add-opens -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org