groovy git commit: GROOVY-8692: Remove DirectFastStringServiceFactory for Groovy 3

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

groovy git commit: GROOVY-8692: Remove DirectFastStringServiceFactory for Groovy 3

paulk
Repository: groovy
Updated Branches:
  refs/heads/master c6a087ba4 -> 8cd5a444f


GROOVY-8692: Remove DirectFastStringServiceFactory for Groovy 3


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/8cd5a444
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/8cd5a444
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/8cd5a444

Branch: refs/heads/master
Commit: 8cd5a444f2542c6dfd15ab0c4cd58673e5df24db
Parents: c6a087b
Author: Paul King <[hidden email]>
Authored: Mon Jul 9 18:26:08 2018 +1000
Committer: Paul King <[hidden email]>
Committed: Mon Jul 9 18:26:08 2018 +1000

----------------------------------------------------------------------
 gradle/upload.gradle                            |  3 +-
 settings.gradle                                 |  1 -
 subprojects/groovy-json-direct/build.gradle     | 22 -----
 .../jsondirect/DirectFastStringService.java     | 47 -----------
 .../DirectFastStringServiceFactory.java         | 86 --------------------
 ....apache.groovy.json.FastStringServiceFactory | 19 -----
 .../DirectFastStringServiceTest.groovy          | 39 ---------
 7 files changed, 1 insertion(+), 216 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/8cd5a444/gradle/upload.gradle
----------------------------------------------------------------------
diff --git a/gradle/upload.gradle b/gradle/upload.gradle
index 0e292e6..30533f8 100644
--- a/gradle/upload.gradle
+++ b/gradle/upload.gradle
@@ -205,8 +205,7 @@ def optionalModules = [
         'groovy-bsf',
         'groovy-cli-commons',
         'groovy-dateutil',
-        'groovy-jaxb',
-        'groovy-json-direct'
+        'groovy-jaxb'
 ]
 
 ext.pomAll = {

http://git-wip-us.apache.org/repos/asf/groovy/blob/8cd5a444/settings.gradle
----------------------------------------------------------------------
diff --git a/settings.gradle b/settings.gradle
index 4e4958f..603370a 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -29,7 +29,6 @@ def subprojects = ['groovy-ant',
         'groovy-jaxb',
         'groovy-jmx',
         'groovy-json',
-        'groovy-json-direct',
         'groovy-jsr223',
         'groovy-nio',
         'groovy-servlet',

http://git-wip-us.apache.org/repos/asf/groovy/blob/8cd5a444/subprojects/groovy-json-direct/build.gradle
----------------------------------------------------------------------
diff --git a/subprojects/groovy-json-direct/build.gradle b/subprojects/groovy-json-direct/build.gradle
deleted file mode 100644
index 68b6ed2..0000000
--- a/subprojects/groovy-json-direct/build.gradle
+++ /dev/null
@@ -1,22 +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.
- */
-dependencies {
-    compile project(':groovy-json')
-    testCompile project(':groovy-test')
-}

http://git-wip-us.apache.org/repos/asf/groovy/blob/8cd5a444/subprojects/groovy-json-direct/src/main/java/org/apache/groovy/jsondirect/DirectFastStringService.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-json-direct/src/main/java/org/apache/groovy/jsondirect/DirectFastStringService.java b/subprojects/groovy-json-direct/src/main/java/org/apache/groovy/jsondirect/DirectFastStringService.java
deleted file mode 100644
index 0d7d4ad..0000000
--- a/subprojects/groovy-json-direct/src/main/java/org/apache/groovy/jsondirect/DirectFastStringService.java
+++ /dev/null
@@ -1,47 +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.apache.groovy.jsondirect;
-
-import org.apache.groovy.json.FastStringService;
-
-import static org.apache.groovy.jsondirect.DirectFastStringServiceFactory.STRING_VALUE_FIELD_OFFSET;
-import static org.apache.groovy.jsondirect.DirectFastStringServiceFactory.WRITE_TO_FINAL_FIELDS;
-import static org.apache.groovy.jsondirect.DirectFastStringServiceFactory.UNSAFE;
-
-/**
- * Internal class for fast processing of Strings during JSON parsing - direct field writing version.
- * Works for JDK 7 and 8 but uses the Unsafe mechanism of Java.
- */
-public class DirectFastStringService implements FastStringService {
-    @Override
-    public char[] toCharArray(String string) {
-        return (char[]) UNSAFE.getObject(string, STRING_VALUE_FIELD_OFFSET);
-    }
-
-    @Override
-    public String noCopyStringFromChars(char[] chars) {
-        if (WRITE_TO_FINAL_FIELDS) {
-            String string = new String();
-            UNSAFE.putObject(string, STRING_VALUE_FIELD_OFFSET, chars);
-            return string;
-        } else {
-            return new String(chars);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/groovy/blob/8cd5a444/subprojects/groovy-json-direct/src/main/java/org/apache/groovy/jsondirect/DirectFastStringServiceFactory.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-json-direct/src/main/java/org/apache/groovy/jsondirect/DirectFastStringServiceFactory.java b/subprojects/groovy-json-direct/src/main/java/org/apache/groovy/jsondirect/DirectFastStringServiceFactory.java
deleted file mode 100644
index 90f0626..0000000
--- a/subprojects/groovy-json-direct/src/main/java/org/apache/groovy/jsondirect/DirectFastStringServiceFactory.java
+++ /dev/null
@@ -1,86 +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.apache.groovy.jsondirect;
-
-import org.apache.groovy.json.FastStringService;
-import org.apache.groovy.json.FastStringServiceFactory;
-import sun.misc.Unsafe;
-
-import java.lang.reflect.Field;
-
-public class DirectFastStringServiceFactory implements FastStringServiceFactory {
-    static final Unsafe UNSAFE;
-    static final long STRING_VALUE_FIELD_OFFSET;
-    private static final boolean ENABLED;
-
-    static final boolean WRITE_TO_FINAL_FIELDS = Boolean.parseBoolean(System.getProperty("groovy.json.faststringutils.write.to.final.fields", "false"));
-    private static final boolean DISABLE = Boolean.parseBoolean(System.getProperty("groovy.json.faststringutils.disable", "false"));
-
-    private static Unsafe loadUnsafe() {
-        try {
-            Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
-            unsafeField.setAccessible(true);
-            return (Unsafe) unsafeField.get(null);
-
-        } catch (Exception e) {
-            return null;
-        }
-    }
-
-    static {
-        UNSAFE = DISABLE ? null : loadUnsafe();
-        ENABLED = UNSAFE != null;
-    }
-
-    private static long getFieldOffset(String fieldName) {
-        if (ENABLED) {
-            try {
-                return UNSAFE.objectFieldOffset(String.class.getDeclaredField(fieldName));
-            } catch (NoSuchFieldException e) {
-                // field undefined
-            }
-        }
-        return -1L;
-    }
-
-    static {
-        STRING_VALUE_FIELD_OFFSET = getFieldOffset("value");
-    }
-
-    @Override
-    public FastStringService getService() {
-        if (STRING_VALUE_FIELD_OFFSET != -1L && valueFieldIsCharArray()) {
-            return new DirectFastStringService();
-        }
-        // safe to return null here because then we'll get the default provider
-        return null;
-    }
-
-    /**
-     * JDK9 Compat Strings enhancement changed the internal representation of the value field from a char[]
-     * to a byte[] (see http://openjdk.java.net/jeps/254).
-     *
-     * @return true if internal String value field is a char[], otherwise false
-     */
-    private static boolean valueFieldIsCharArray() {
-        Object o = UNSAFE.getObject("", STRING_VALUE_FIELD_OFFSET);
-        return (o instanceof char[]);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/groovy/blob/8cd5a444/subprojects/groovy-json-direct/src/main/resources/META-INF/services/org.apache.groovy.json.FastStringServiceFactory
----------------------------------------------------------------------
diff --git a/subprojects/groovy-json-direct/src/main/resources/META-INF/services/org.apache.groovy.json.FastStringServiceFactory b/subprojects/groovy-json-direct/src/main/resources/META-INF/services/org.apache.groovy.json.FastStringServiceFactory
deleted file mode 100644
index cbb3713..0000000
--- a/subprojects/groovy-json-direct/src/main/resources/META-INF/services/org.apache.groovy.json.FastStringServiceFactory
+++ /dev/null
@@ -1,19 +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.
-#
-org.apache.groovy.jsondirect.DirectFastStringServiceFactory

http://git-wip-us.apache.org/repos/asf/groovy/blob/8cd5a444/subprojects/groovy-json-direct/src/test/groovy/org/apache/groovy/jsondirect/DirectFastStringServiceTest.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-json-direct/src/test/groovy/org/apache/groovy/jsondirect/DirectFastStringServiceTest.groovy b/subprojects/groovy-json-direct/src/test/groovy/org/apache/groovy/jsondirect/DirectFastStringServiceTest.groovy
deleted file mode 100644
index fe05828..0000000
--- a/subprojects/groovy-json-direct/src/test/groovy/org/apache/groovy/jsondirect/DirectFastStringServiceTest.groovy
+++ /dev/null
@@ -1,39 +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.apache.groovy.jsondirect
-
-import org.apache.groovy.json.FastStringService
-
-class DirectFastStringServiceTest extends GroovyTestCase {
-
-    FastStringService service = new DirectFastStringServiceFactory().service
-
-    void testToCharArray() {
-        if (!service) return
-        def str = "some test"
-        assert service.toCharArray(str) == str.toCharArray()
-    }
-
-    void testNoCopyStringFromChars() {
-        if (!service) return
-        def source = "äöüliu"
-        def chars = source.toCharArray()
-        assert service.noCopyStringFromChars(chars) == source
-    }
-}