You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by jw...@apache.org on 2017/07/08 20:44:39 UTC
groovy git commit: rename Java8 package from vm8 to v8 for
consistency (closes #562)
Repository: groovy
Updated Branches:
refs/heads/master 928782e14 -> a30f876a6
rename Java8 package from vm8 to v8 for consistency (closes #562)
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/a30f876a
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/a30f876a
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/a30f876a
Branch: refs/heads/master
Commit: a30f876a6c6d1428c326d0798f24cdb228b534d4
Parents: 928782e
Author: John Wagenleitner <jw...@apache.org>
Authored: Sat Jul 8 12:55:39 2017 -0700
Committer: John Wagenleitner <jw...@apache.org>
Committed: Sat Jul 8 12:55:39 2017 -0700
----------------------------------------------------------------------
build.gradle | 3 +
gradle/docs.gradle | 2 +-
.../groovy/vmplugin/VMPluginFactory.java | 2 +-
.../org/codehaus/groovy/vmplugin/v8/Java8.java | 66 ++++++++++++++++++++
.../vmplugin/v8/PluginDefaultGroovyMethods.java | 45 +++++++++++++
.../org/codehaus/groovy/vmplugin/vm8/Java8.java | 66 --------------------
.../vm8/PluginDefaultGroovyMethods.java | 45 -------------
.../v8/PluginDefaultGroovyMethodsSCTest.groovy | 26 ++++++++
.../v8/PluginDefaultGroovyMethodsTest.groovy | 45 +++++++++++++
.../vm8/PluginDefaultGroovyMethodsSCTest.groovy | 26 --------
.../vm8/PluginDefaultGroovyMethodsTest.groovy | 45 -------------
11 files changed, 187 insertions(+), 184 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/a30f876a/build.gradle
----------------------------------------------------------------------
diff --git a/build.gradle b/build.gradle
index ac701d6..e7ddd6f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -272,6 +272,7 @@ sourceSets {
"$generatedDirectory/src/main"
]
if (!JavaVersion.current().isJava8Compatible()) {
+ exclude '**/v8/*'
exclude '**/vm8/*'
}
}
@@ -281,6 +282,7 @@ sourceSets {
"$generatedDirectory/src/main"
]
if (!JavaVersion.current().isJava8Compatible()) {
+ exclude '**/v8/*'
exclude '**/vm8/*'
}
}
@@ -302,6 +304,7 @@ sourceSets {
groovy {
srcDirs = ['src/test']
if (!JavaVersion.current().isJava8Compatible()) {
+ exclude '**/v8/*'
exclude '**/vm8/*'
}
}
http://git-wip-us.apache.org/repos/asf/groovy/blob/a30f876a/gradle/docs.gradle
----------------------------------------------------------------------
diff --git a/gradle/docs.gradle b/gradle/docs.gradle
index 90fbe55..e434afc 100644
--- a/gradle/docs.gradle
+++ b/gradle/docs.gradle
@@ -156,7 +156,7 @@ task docGDK {
arg(value: 'org.codehaus.groovy.runtime.SocketGroovyMethods')
arg(value: 'org.codehaus.groovy.runtime.StringGroovyMethods')
arg(value: 'org.codehaus.groovy.vmplugin.v5.PluginDefaultGroovyMethods')
- arg(value: 'org.codehaus.groovy.vmplugin.vm8.PluginDefaultGroovyMethods')
+ arg(value: 'org.codehaus.groovy.vmplugin.v8.PluginDefaultGroovyMethods')
// TODO don't hard-code these
arg(value: 'subprojects/groovy-sql/src/main/java/org/codehaus/groovy/runtime/SqlGroovyMethods.java')
arg(value: 'subprojects/groovy-swing/src/main/java/org/codehaus/groovy/runtime/SwingGroovyMethods.java')
http://git-wip-us.apache.org/repos/asf/groovy/blob/a30f876a/src/main/org/codehaus/groovy/vmplugin/VMPluginFactory.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/vmplugin/VMPluginFactory.java b/src/main/org/codehaus/groovy/vmplugin/VMPluginFactory.java
index fe625fb..a456e5a 100644
--- a/src/main/org/codehaus/groovy/vmplugin/VMPluginFactory.java
+++ b/src/main/org/codehaus/groovy/vmplugin/VMPluginFactory.java
@@ -29,7 +29,7 @@ import org.codehaus.groovy.vmplugin.v7.Java7;
public class VMPluginFactory {
private static final String JDK8_CLASSNAME_CHECK = "java.util.Optional";
- private static final String JDK8_PLUGIN_NAME = "org.codehaus.groovy.vmplugin.vm8.Java8";
+ private static final String JDK8_PLUGIN_NAME = "org.codehaus.groovy.vmplugin.v8.Java8";
private static final VMPlugin plugin;
http://git-wip-us.apache.org/repos/asf/groovy/blob/a30f876a/src/main/org/codehaus/groovy/vmplugin/v8/Java8.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/vmplugin/v8/Java8.java b/src/main/org/codehaus/groovy/vmplugin/v8/Java8.java
new file mode 100644
index 0000000..3a659b7
--- /dev/null
+++ b/src/main/org/codehaus/groovy/vmplugin/v8/Java8.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.codehaus.groovy.vmplugin.v8;
+
+import org.codehaus.groovy.ast.AnnotationNode;
+import org.codehaus.groovy.vmplugin.v7.Java7;
+
+import java.lang.annotation.ElementType;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Java 8 based functions.
+ *
+ * @since 2.5.0
+ */
+public class Java8 extends Java7 {
+
+ private final Class<?>[] PLUGIN_DGM;
+
+ public Java8() {
+ super();
+ List<Class<?>> dgmClasses = new ArrayList<>();
+ Collections.addAll(dgmClasses, (Class<?>[]) super.getPluginDefaultGroovyMethods());
+ dgmClasses.add(PluginDefaultGroovyMethods.class);
+ PLUGIN_DGM = dgmClasses.toArray(new Class<?>[0]);
+ }
+
+ @Override
+ public Class<?>[] getPluginDefaultGroovyMethods() {
+ return PLUGIN_DGM;
+ }
+
+ @Override
+ public int getVersion() {
+ return 8;
+ }
+
+ @Override
+ protected int getElementCode(ElementType value) {
+ switch (value) {
+ case TYPE_PARAMETER:
+ return AnnotationNode.TYPE_PARAMETER_TARGET;
+ case TYPE_USE:
+ return AnnotationNode.TYPE_USE_TARGET;
+ }
+ return super.getElementCode(value);
+ }
+}
http://git-wip-us.apache.org/repos/asf/groovy/blob/a30f876a/src/main/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethods.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethods.java b/src/main/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethods.java
new file mode 100644
index 0000000..b26a381
--- /dev/null
+++ b/src/main/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethods.java
@@ -0,0 +1,45 @@
+/*
+ * 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.v8;
+
+import java.util.Optional;
+
+/**
+ * Defines new Groovy methods which appear on normal JDK 8
+ * classes inside the Groovy environment.
+ *
+ * @since 2.5.0
+ */
+public class PluginDefaultGroovyMethods {
+
+ // No instances, static methods only
+ private PluginDefaultGroovyMethods() {
+ }
+
+ /**
+ * Coerce an Optional instance to a boolean value.
+ *
+ * @param optional the Optional
+ * @return {@code true} if a value is present, otherwise {@code false}
+ */
+ public static boolean asBoolean(Optional<?> optional) {
+ return optional.isPresent();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/groovy/blob/a30f876a/src/main/org/codehaus/groovy/vmplugin/vm8/Java8.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/vmplugin/vm8/Java8.java b/src/main/org/codehaus/groovy/vmplugin/vm8/Java8.java
deleted file mode 100644
index 4656af1..0000000
--- a/src/main/org/codehaus/groovy/vmplugin/vm8/Java8.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.vm8;
-
-import org.codehaus.groovy.ast.AnnotationNode;
-import org.codehaus.groovy.vmplugin.v7.Java7;
-
-import java.lang.annotation.ElementType;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Java 8 based functions.
- *
- * @since 2.5.0
- */
-public class Java8 extends Java7 {
-
- private final Class<?>[] PLUGIN_DGM;
-
- public Java8() {
- super();
- List<Class<?>> dgmClasses = new ArrayList<>();
- Collections.addAll(dgmClasses, (Class<?>[]) super.getPluginDefaultGroovyMethods());
- dgmClasses.add(PluginDefaultGroovyMethods.class);
- PLUGIN_DGM = dgmClasses.toArray(new Class<?>[0]);
- }
-
- @Override
- public Class<?>[] getPluginDefaultGroovyMethods() {
- return PLUGIN_DGM;
- }
-
- @Override
- public int getVersion() {
- return 8;
- }
-
- @Override
- protected int getElementCode(ElementType value) {
- switch (value) {
- case TYPE_PARAMETER:
- return AnnotationNode.TYPE_PARAMETER_TARGET;
- case TYPE_USE:
- return AnnotationNode.TYPE_USE_TARGET;
- }
- return super.getElementCode(value);
- }
-}
http://git-wip-us.apache.org/repos/asf/groovy/blob/a30f876a/src/main/org/codehaus/groovy/vmplugin/vm8/PluginDefaultGroovyMethods.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/vmplugin/vm8/PluginDefaultGroovyMethods.java b/src/main/org/codehaus/groovy/vmplugin/vm8/PluginDefaultGroovyMethods.java
deleted file mode 100644
index 7ae5321..0000000
--- a/src/main/org/codehaus/groovy/vmplugin/vm8/PluginDefaultGroovyMethods.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.vm8;
-
-import java.util.Optional;
-
-/**
- * Defines new Groovy methods which appear on normal JDK 8
- * classes inside the Groovy environment.
- *
- * @since 2.5.0
- */
-public class PluginDefaultGroovyMethods {
-
- // No instances, static methods only
- private PluginDefaultGroovyMethods() {
- }
-
- /**
- * Coerce an Optional instance to a boolean value.
- *
- * @param optional the Optional
- * @return {@code true} if a value is present, otherwise {@code false}
- */
- public static boolean asBoolean(Optional<?> optional) {
- return optional.isPresent();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/groovy/blob/a30f876a/src/test/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethodsSCTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethodsSCTest.groovy b/src/test/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethodsSCTest.groovy
new file mode 100644
index 0000000..3c22368
--- /dev/null
+++ b/src/test/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethodsSCTest.groovy
@@ -0,0 +1,26 @@
+/*
+ * 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.v8
+
+import org.codehaus.groovy.classgen.asm.sc.StaticCompilationTestSupport
+
+class PluginDefaultGroovyMethodsSCTest
+ extends PluginDefaultGroovyMethodsTest
+ implements StaticCompilationTestSupport {
+}
http://git-wip-us.apache.org/repos/asf/groovy/blob/a30f876a/src/test/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethodsTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethodsTest.groovy b/src/test/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethodsTest.groovy
new file mode 100644
index 0000000..6139654
--- /dev/null
+++ b/src/test/org/codehaus/groovy/vmplugin/v8/PluginDefaultGroovyMethodsTest.groovy
@@ -0,0 +1,45 @@
+/*
+ * 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.v8
+
+import groovy.transform.stc.StaticTypeCheckingTestCase
+
+class PluginDefaultGroovyMethodsTest extends StaticTypeCheckingTestCase {
+
+ // GROOVY-7611
+ void testOptionalAsBoolean() {
+ assertScript '''
+ boolean m() {
+ assert Optional.of('foo')
+ assert !Optional.empty()
+ assert !Optional.ofNullable(null)
+
+ def x = Optional.empty() ? 1 : -1
+ assert x == -1
+
+ x = Optional.ofNullable(null) ? 1 : -1
+ assert x == -1
+
+ Optional.empty()
+ }
+ assert !m()
+ '''
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/groovy/blob/a30f876a/src/test/org/codehaus/groovy/vmplugin/vm8/PluginDefaultGroovyMethodsSCTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/vmplugin/vm8/PluginDefaultGroovyMethodsSCTest.groovy b/src/test/org/codehaus/groovy/vmplugin/vm8/PluginDefaultGroovyMethodsSCTest.groovy
deleted file mode 100644
index 373403c..0000000
--- a/src/test/org/codehaus/groovy/vmplugin/vm8/PluginDefaultGroovyMethodsSCTest.groovy
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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.vm8
-
-import org.codehaus.groovy.classgen.asm.sc.StaticCompilationTestSupport
-
-class PluginDefaultGroovyMethodsSCTest
- extends PluginDefaultGroovyMethodsTest
- implements StaticCompilationTestSupport {
-}
http://git-wip-us.apache.org/repos/asf/groovy/blob/a30f876a/src/test/org/codehaus/groovy/vmplugin/vm8/PluginDefaultGroovyMethodsTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/vmplugin/vm8/PluginDefaultGroovyMethodsTest.groovy b/src/test/org/codehaus/groovy/vmplugin/vm8/PluginDefaultGroovyMethodsTest.groovy
deleted file mode 100644
index 5afe05e..0000000
--- a/src/test/org/codehaus/groovy/vmplugin/vm8/PluginDefaultGroovyMethodsTest.groovy
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.vm8
-
-import groovy.transform.stc.StaticTypeCheckingTestCase
-
-class PluginDefaultGroovyMethodsTest extends StaticTypeCheckingTestCase {
-
- // GROOVY-7611
- void testOptionalAsBoolean() {
- assertScript '''
- boolean m() {
- assert Optional.of('foo')
- assert !Optional.empty()
- assert !Optional.ofNullable(null)
-
- def x = Optional.empty() ? 1 : -1
- assert x == -1
-
- x = Optional.ofNullable(null) ? 1 : -1
- assert x == -1
-
- Optional.empty()
- }
- assert !m()
- '''
- }
-
-}