You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2019/04/18 03:09:46 UTC

[groovy] branch master updated (1ec71b0 -> 53345dc)

This is an automated email from the ASF dual-hosted git repository.

paulk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git.


    from 1ec71b0  GROOVY-9080: MarkupTemplateEngine uses invalid XML entity for escaping double quotes
     new 3624f64  fix unintended illegal access
     new 53345dc  Allow illegal access scenarios to be tested using -Pgroovy.force.illegal.access=true property.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 gradle/test.gradle                                 |  2 ++
 .../IllegalAccessScenariosTest.groovy}             | 29 ++++++++++++++--------
 .../groovy/jmx/builder/JmxBeansFactoryTest.groovy  |  2 +-
 3 files changed, 21 insertions(+), 12 deletions(-)
 copy src/test/{org/codehaus/groovy/runtime/DefaultGroovyStaticMethodsTest.groovy => groovy/IllegalAccessScenariosTest.groovy} (52%)


[groovy] 01/02: fix unintended illegal access

Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 3624f64b47af52105de4bf30914fe8fda26daf38
Author: Paul King <pa...@asert.com.au>
AuthorDate: Thu Apr 18 12:35:22 2019 +1000

    fix unintended illegal access
---
 .../src/test/groovy/groovy/jmx/builder/JmxBeansFactoryTest.groovy       | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/subprojects/groovy-jmx/src/test/groovy/groovy/jmx/builder/JmxBeansFactoryTest.groovy b/subprojects/groovy-jmx/src/test/groovy/groovy/jmx/builder/JmxBeansFactoryTest.groovy
index 0340419..ddca2fe 100644
--- a/subprojects/groovy-jmx/src/test/groovy/groovy/jmx/builder/JmxBeansFactoryTest.groovy
+++ b/subprojects/groovy-jmx/src/test/groovy/groovy/jmx/builder/JmxBeansFactoryTest.groovy
@@ -33,7 +33,7 @@ class JmxBeansFactoryTest extends GroovyTestCase {
         def maps = builder.beans(obj1, obj2)
 
         assert maps
-        assert maps.size == 2
+        assert maps.size() == 2
 
         // test MockManagedObject map
         def map = maps[0]


[groovy] 02/02: Allow illegal access scenarios to be tested using -Pgroovy.force.illegal.access=true property.

Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 53345dc58a368c63e166d0a8a1daae61fa6dcaf0
Author: Paul King <pa...@asert.com.au>
AuthorDate: Thu Apr 18 13:09:10 2019 +1000

    Allow illegal access scenarios to be tested using -Pgroovy.force.illegal.access=true property.
    
    This doesn't affect the groovy runtime/compiler, it is just a system property which decides
    whether the tests will be run or not. We will try to have the build as warning free as possible
    but still want the ability to test any still supported functionality which generates warnings.
    We may evolve this approach over time.
---
 gradle/test.gradle                                |  2 ++
 src/test/groovy/IllegalAccessScenariosTest.groovy | 39 +++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/gradle/test.gradle b/gradle/test.gradle
index a2dae8a..d121b37 100644
--- a/gradle/test.gradle
+++ b/gradle/test.gradle
@@ -20,9 +20,11 @@ allprojects {
     tasks.withType(Test) {
         def jdk8 = ['-XX:+UseConcMarkSweepGC']
         def jdk9 = ['-Djava.locale.providers=COMPAT,SPI']
+//        def jdk9 = ['-Djava.locale.providers=COMPAT,SPI', '--illegal-access=debug']
         def common = ['-ea', "-Xms${groovyJUnit_ms}", "-Xmx${groovyJUnit_mx}", "-Duser.language=en" ]
         if (JavaVersion.current().isJava9Compatible()) {
             jvmArgs (*common, *jdk9)
+            systemProperty "groovy.force.illegal.access", findProperty("groovy.force.illegal.access")
         } else if (JavaVersion.current().isJava8Compatible()) {
             jvmArgs (*common, *jdk8)
         } else {
diff --git a/src/test/groovy/IllegalAccessScenariosTest.groovy b/src/test/groovy/IllegalAccessScenariosTest.groovy
new file mode 100644
index 0000000..44096b0
--- /dev/null
+++ b/src/test/groovy/IllegalAccessScenariosTest.groovy
@@ -0,0 +1,39 @@
+/*
+ *  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 groovy
+
+import static groovy.test.GroovyAssert.isAtLeastJdk
+import static org.apache.groovy.util.SystemUtil.getBooleanSafe
+
+/**
+ * Tests for permissive member access. Typically such access is only allowed in Java via means such
+ * as reflection.
+ *
+ * In JDK versions < 9, Groovy supports permissive access and no warnings are given by the JDK.
+ * In JDK versions >= 9, Groovy supports permissive access but the JDK gives illegal access warnings.
+ * At some point, the JDK may further restrict permissive access and Groovy's support for this feature may be limited.
+ */
+class IllegalAccessScenariosTest extends GroovyTestCase {
+    void testPrivateFieldAccess() {
+        if (isAtLeastJdk('9.0') && !getBooleanSafe('groovy.force.illegal.access')) return
+        def items = [1, 2, 3]
+        // size is a private field in ArrayList
+        assert items.size == 3
+    }
+}