From commits-return-7175-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Wed Aug 8 07:06:24 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id BC5AC180600 for ; Wed, 8 Aug 2018 07:06:23 +0200 (CEST) Received: (qmail 40114 invoked by uid 500); 8 Aug 2018 05:06:22 -0000 Mailing-List: contact commits-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list commits@groovy.apache.org Received: (qmail 40105 invoked by uid 99); 8 Aug 2018 05:06:22 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Aug 2018 05:06:22 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9B0E7DFCBA; Wed, 8 Aug 2018 05:06:22 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: paulk@apache.org To: commits@groovy.apache.org Message-Id: <78ffa51ceba840fc8f1fffb04def7dec@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: groovy git commit: support detecting JDK9+ in vmplugin Date: Wed, 8 Aug 2018 05:06:22 +0000 (UTC) Repository: groovy Updated Branches: refs/heads/GROOVY_2_5_X 3d3df8daf -> 6cabae08f support detecting JDK9+ in vmplugin Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/6cabae08 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/6cabae08 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/6cabae08 Branch: refs/heads/GROOVY_2_5_X Commit: 6cabae08f1a4652fef5b198b633a8fb1daff368e Parents: 3d3df8d Author: Paul King Authored: Wed Aug 8 09:37:48 2018 +1000 Committer: Paul King Committed: Wed Aug 8 15:06:07 2018 +1000 ---------------------------------------------------------------------- .../org/codehaus/groovy/vmplugin/VMPlugin.java | 4 +-- .../groovy/vmplugin/VMPluginFactory.java | 11 +++++-- .../org/codehaus/groovy/vmplugin/v9/Java9.java | 31 ++++++++++++++++++++ 3 files changed, 40 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/6cabae08/src/main/java/org/codehaus/groovy/vmplugin/VMPlugin.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/codehaus/groovy/vmplugin/VMPlugin.java b/src/main/java/org/codehaus/groovy/vmplugin/VMPlugin.java index 449398a..88b2076 100644 --- a/src/main/java/org/codehaus/groovy/vmplugin/VMPlugin.java +++ b/src/main/java/org/codehaus/groovy/vmplugin/VMPlugin.java @@ -27,8 +27,6 @@ import java.lang.reflect.Method; /** * Interface to access VM version based actions. * This interface is for internal use only! - * - * @author Jochen Theodorou */ public interface VMPlugin { void setAdditionalClassInformation(ClassNode c); @@ -58,7 +56,7 @@ public interface VMPlugin { /** * Gives the version the plugin is made for - * @return 5 for jdk5, 6 for jdk6, 7 for jdk7, 8 for jdk8 or higher + * @return 7 for jdk7, 8 for jdk8, 9 for jdk9 or higher */ int getVersion(); http://git-wip-us.apache.org/repos/asf/groovy/blob/6cabae08/src/main/java/org/codehaus/groovy/vmplugin/VMPluginFactory.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/codehaus/groovy/vmplugin/VMPluginFactory.java b/src/main/java/org/codehaus/groovy/vmplugin/VMPluginFactory.java index a456e5a..25a1269 100644 --- a/src/main/java/org/codehaus/groovy/vmplugin/VMPluginFactory.java +++ b/src/main/java/org/codehaus/groovy/vmplugin/VMPluginFactory.java @@ -24,19 +24,24 @@ import org.codehaus.groovy.vmplugin.v7.Java7; * Factory class to get functionality based on the VM version. * The usage of this class is not for public use, only for the * runtime. - * @author Jochen Theodorou */ public class VMPluginFactory { private static final String JDK8_CLASSNAME_CHECK = "java.util.Optional"; + private static final String JDK9_CLASSNAME_CHECK = "java.lang.Module"; + private static final String JDK8_PLUGIN_NAME = "org.codehaus.groovy.vmplugin.v8.Java8"; + private static final String JDK9_PLUGIN_NAME = "org.codehaus.groovy.vmplugin.v9.Java9"; private static final VMPlugin plugin; static { - VMPlugin target = createPlugin(JDK8_CLASSNAME_CHECK, JDK8_PLUGIN_NAME); + VMPlugin target = createPlugin(JDK9_CLASSNAME_CHECK, JDK9_PLUGIN_NAME); if (target == null) { - target = new Java7(); + target = createPlugin(JDK8_CLASSNAME_CHECK, JDK8_PLUGIN_NAME); + if (target == null) { + target = new Java7(); + } } plugin = target; } http://git-wip-us.apache.org/repos/asf/groovy/blob/6cabae08/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java b/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java new file mode 100644 index 0000000..7468581 --- /dev/null +++ b/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java @@ -0,0 +1,31 @@ +/* + * 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.codehaus.groovy.vmplugin.v9; + +import org.codehaus.groovy.vmplugin.v8.Java8; + +/** + * Java 9 based functions will be added here if needed. + */ +public class Java9 extends Java8 { + @Override + public int getVersion() { + return 9; + } +}