From c6476a761ef674aa371a7f56460e7448da1d39d874201444a6a2274b6dcb20bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Fri, 3 May 2024 13:11:00 +0200 Subject: [PATCH] Sync from SUSE:SLFO:Main google-gson revision 6e930f2e9104e2ad1425d4c923249860 --- .gitattributes | 23 ++++ google-gson.changes | 72 ++++++++++++ google-gson.spec | 95 ++++++++++++++++ gson-parent-2.8.9.tar.gz | 3 + no-template-plugin.patch | 222 +++++++++++++++++++++++++++++++++++++ osgi-export-internal.patch | 25 +++++ 6 files changed, 440 insertions(+) create mode 100644 .gitattributes create mode 100644 google-gson.changes create mode 100644 google-gson.spec create mode 100644 gson-parent-2.8.9.tar.gz create mode 100644 no-template-plugin.patch create mode 100644 osgi-export-internal.patch diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/google-gson.changes b/google-gson.changes new file mode 100644 index 0000000..3e64d02 --- /dev/null +++ b/google-gson.changes @@ -0,0 +1,72 @@ +------------------------------------------------------------------- +Sat Sep 9 13:38:45 UTC 2023 - Fridrich Strba + +- Reproducible builds: use SOURCE_DATE_EPOCH for timestamp + +------------------------------------------------------------------- +Fri Apr 1 08:00:10 UTC 2022 - Fridrich Strba + +- Build with Java >= 9 in order to produce a modular jar by + compiling the module-info.java sources with all other classes + built with release 8 and still compatible with Java 8 +- Removed patch: + * allow-build-with-java8.patch + + not needed in this setting + +------------------------------------------------------------------- +Thu Mar 31 09:40:46 UTC 2022 - Fridrich Strba + +- Upgrade to version 2.8.9 (jsc#SLE-24261) + * Changes + + Make OSGi bundle's dependency on sun.misc optional. + + Deprecate Gson.excluder() exposing internal Excluder class. + + Prevent Java deserialization of internal classes. + + Improve number strategy implementation. + + Fix LongSerializationPolicy null handling being inconsistent + with Gson. + + Support arbitrary Number implementation for Object and Number + deserialization. + + Bump proguard-maven-plugin from 2.4.0 to 2.5.1. + + Don't exclude static local classes. + + Fix RuntimeTypeAdapterFactory depending on internal Streams + class. + + Improve Maven build. + + Make dependency on java.sql optional. + * fixes bsc#1199064, CVE-2022-25647 +- Removed patch: + * sun-misc.patch + + integrated upstream + +------------------------------------------------------------------- +Tue Mar 22 10:06:36 UTC 2022 - Fridrich Strba + +- Build with source and target levels 8 + +------------------------------------------------------------------- +Tue Oct 19 07:08:34 UTC 2021 - Fridrich Strba + +- Upgrade to version 2.8.8 + * Changes + + Fixed issue with recursive types. + + Better behaviour with Java 9+ and Unsafe if there is a + security manager. + + EnumTypeAdapter now works better when ProGuard has obfuscated + enum fields. +- Removed patch: + * fix-test.patch + + integrated upstream +- Modified patches: + * no-template-plugin.patch + * osgi-export-internal.patch + + rediff to changed context +- Added patches: + * allow-build-with-java8.patch + + lower the unnecessary requirement of Java 9 + * sun-misc.patch + + make import of sun.misc optional since not all versions of + jdk export it + +------------------------------------------------------------------- +Fri Nov 1 08:18:35 UTC 2019 - Fridrich Strba + +- Initial packaging of google-gson 2.8.5 diff --git a/google-gson.spec b/google-gson.spec new file mode 100644 index 0000000..fb1b828 --- /dev/null +++ b/google-gson.spec @@ -0,0 +1,95 @@ +# +# spec file for package google-gson +# +# Copyright (c) 2023 SUSE LLC +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +Name: google-gson +Version: 2.8.9 +Release: 0 +Summary: Java lib for conversion of Java objects into JSON representation +License: Apache-2.0 +URL: https://github.com/google/gson +Source0: https://github.com/google/gson/archive/gson-parent-%{version}.tar.gz +Patch0: osgi-export-internal.patch +# Remove dependency on unavailable templating-maven-plugin +Patch1: no-template-plugin.patch +BuildRequires: fdupes +BuildRequires: java-devel >= 9 +BuildRequires: maven-local +BuildRequires: mvn(javax.annotation:jsr250-api) +BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) +BuildArch: noarch + +%description +Gson is a Java library that can be used to convert a Java object into its +JSON representation. It can also be used to convert a JSON string into an +equivalent Java object. Gson can work with arbitrary Java objects including +pre-existing objects that you do not have source-code of. + +%package javadoc +Summary: API documentation for %{name} + +%description javadoc +This package contains the API documentation for %{name}. + +%prep +%setup -q -n gson-gson-parent-%{version} +%patch0 -p1 +%patch1 -p1 + +# remove unnecessary dependency on parent POM +%pom_remove_parent + +# presence of these files breaks builds with Java 8 +# find -name "module-info.java" -print -delete + +# Use felix maven-bundle-plugin only for OSGi metadata +%pom_remove_plugin :bnd-maven-plugin gson +%pom_remove_plugin :templating-maven-plugin gson +%pom_remove_plugin :copy-rename-maven-plugin gson +%pom_remove_plugin :proguard-maven-plugin gson +%pom_add_plugin "org.apache.felix:maven-bundle-plugin" gson " + + <_include>bnd.bnd + + + + + create-manifest + process-classes + manifest + + " + +%pom_xpath_set "pom:plugins/pom:plugin[pom:artifactId[text()='maven-compiler-plugin']]/pom:configuration" "8" + +%build +%{mvn_build} -f -- \ + -Dproject.build.outputTimestamp=$(date -u -d @${SOURCE_DATE_EPOCH:-$(date +%%s)} +%%Y-%%m-%%dT%%H:%%M:%%SZ) \ + -Dsource=8 + +%install +%mvn_install +%fdupes -s %{buildroot}%{_javadocdir} + +%files -f .mfiles +%license LICENSE +%doc README.md CHANGELOG.md UserGuide.md + +%files javadoc -f .mfiles-javadoc +%license LICENSE + +%changelog diff --git a/gson-parent-2.8.9.tar.gz b/gson-parent-2.8.9.tar.gz new file mode 100644 index 0000000..f6e076e --- /dev/null +++ b/gson-parent-2.8.9.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7c340e56dded5e033f6ced33d4e868ec1fcf17a3bd29dce51c8b4c39ccdc1f0b +size 400745 diff --git a/no-template-plugin.patch b/no-template-plugin.patch new file mode 100644 index 0000000..5e21901 --- /dev/null +++ b/no-template-plugin.patch @@ -0,0 +1,222 @@ +--- a/gson/src/main/java-templates/com/google/gson/internal/GsonBuildConfig.java ++++ /dev/null +@@ -1,32 +0,0 @@ +-/* +- * Copyright (C) 2018 The Gson authors +- * +- * Licensed 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 com.google.gson.internal; +- +-/** +- * Build configuration for Gson. This file is automatically populated by +- * templating-maven-plugin and .java/.class files are generated for use in Gson. +- * +- * @author Inderjeet Singh +- */ +-public final class GsonBuildConfig { +- // Based on https://stackoverflow.com/questions/2469922/generate-a-version-java-file-in-maven +- +- /** This field is automatically populated by Maven when a build is triggered */ +- public static final String VERSION = "${project.version}"; +- +- private GsonBuildConfig() { } +-} +--- a/gson/src/main/java/com/google/gson/Gson.java ++++ b/gson/src/main/java/com/google/gson/Gson.java +@@ -37,7 +37,6 @@ import java.util.concurrent.atomic.AtomicLongArray; + + import com.google.gson.internal.ConstructorConstructor; + import com.google.gson.internal.Excluder; +-import com.google.gson.internal.GsonBuildConfig; + import com.google.gson.internal.Primitives; + import com.google.gson.internal.Streams; + import com.google.gson.internal.bind.ArrayTypeAdapter; +@@ -462,7 +461,7 @@ public final class Gson { + return candidate; + } + } +- throw new IllegalArgumentException("GSON (" + GsonBuildConfig.VERSION + ") cannot handle " + type); ++ throw new IllegalArgumentException("GSON cannot handle " + type); + } finally { + threadCalls.remove(type); + +@@ -704,10 +703,6 @@ public final class Gson { + ((TypeAdapter) adapter).write(writer, src); + } catch (IOException e) { + throw new JsonIOException(e); +- } catch (AssertionError e) { +- AssertionError error = new AssertionError("AssertionError (GSON " + GsonBuildConfig.VERSION + "): " + e.getMessage()); +- error.initCause(e); +- throw error; + } finally { + writer.setLenient(oldLenient); + writer.setHtmlSafe(oldHtmlSafe); +@@ -784,10 +779,6 @@ public final class Gson { + Streams.write(jsonElement, writer); + } catch (IOException e) { + throw new JsonIOException(e); +- } catch (AssertionError e) { +- AssertionError error = new AssertionError("AssertionError (GSON " + GsonBuildConfig.VERSION + "): " + e.getMessage()); +- error.initCause(e); +- throw error; + } finally { + writer.setLenient(oldLenient); + writer.setHtmlSafe(oldHtmlSafe); +@@ -945,10 +936,6 @@ public final class Gson { + } catch (IOException e) { + // TODO(inder): Figure out whether it is indeed right to rethrow this as JsonSyntaxException + throw new JsonSyntaxException(e); +- } catch (AssertionError e) { +- AssertionError error = new AssertionError("AssertionError (GSON " + GsonBuildConfig.VERSION + "): " + e.getMessage()); +- error.initCause(e); +- throw error; + } finally { + reader.setLenient(oldLenient); + } +--- a/gson/src/test/java/com/google/gson/functional/GsonVersionDiagnosticsTest.java ++++ /dev/null +@@ -1,96 +0,0 @@ +-/* +- * Copyright (C) 2018 Gson Authors +- * +- * Licensed 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 com.google.gson.functional; +- +-import java.io.IOException; +-import java.util.regex.Pattern; +- +-import org.junit.Before; +-import org.junit.Test; +- +-import com.google.gson.Gson; +-import com.google.gson.GsonBuilder; +-import com.google.gson.TypeAdapter; +-import com.google.gson.stream.JsonReader; +-import com.google.gson.stream.JsonWriter; +- +-import junit.framework.TestCase; +- +-/** +- * Functional tests to validate printing of Gson version on AssertionErrors +- * +- * @author Inderjeet Singh +- */ +-public class GsonVersionDiagnosticsTest extends TestCase { +- private static final Pattern GSON_VERSION_PATTERN = Pattern.compile("(\\(GSON \\d\\.\\d\\.\\d)(?:[-.][A-Z]+)?\\)$"); +- +- private Gson gson; +- +- @Before +- public void setUp() { +- gson = new GsonBuilder().registerTypeAdapter(TestType.class, new TypeAdapter() { +- @Override public void write(JsonWriter out, TestType value) { +- throw new AssertionError("Expected during serialization"); +- } +- @Override public TestType read(JsonReader in) throws IOException { +- throw new AssertionError("Expected during deserialization"); +- } +- }).create(); +- } +- +- @Test +- public void testVersionPattern() { +- assertTrue(GSON_VERSION_PATTERN.matcher("(GSON 2.8.5)").matches()); +- assertTrue(GSON_VERSION_PATTERN.matcher("(GSON 2.8.5-SNAPSHOT)").matches()); +- } +- +- @Test +- public void testAssertionErrorInSerializationPrintsVersion() { +- try { +- gson.toJson(new TestType()); +- fail(); +- } catch (AssertionError expected) { +- ensureAssertionErrorPrintsGsonVersion(expected); +- } +- } +- +- @Test +- public void testAssertionErrorInDeserializationPrintsVersion() { +- try { +- gson.fromJson("{'a':'abc'}", TestType.class); +- fail(); +- } catch (AssertionError expected) { +- ensureAssertionErrorPrintsGsonVersion(expected); +- } +- } +- +- private void ensureAssertionErrorPrintsGsonVersion(AssertionError expected) { +- String msg = expected.getMessage(); +- // System.err.println(msg); +- int start = msg.indexOf("(GSON"); +- assertTrue(start > 0); +- int end = msg.indexOf("):") + 1; +- assertTrue(end > 0 && end > start + 6); +- String version = msg.substring(start, end); +- // System.err.println(version); +- assertTrue(GSON_VERSION_PATTERN.matcher(version).matches()); +- } +- +- private static final class TestType { +- @SuppressWarnings("unused") +- String a; +- } +-} +--- a/gson/src/test/java/com/google/gson/internal/GsonBuildConfigTest.java ++++ /dev/null +@@ -1,33 +0,0 @@ +-/* +- * Copyright (C) 2018 The Gson authors +- * +- * Licensed 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 com.google.gson.internal; +- +-import static org.junit.Assert.assertFalse; +- +-import org.junit.Test; +- +-/** +- * Unit tests for {@code GsonBuildConfig} +- * +- * @author Inderjeet Singh +- */ +-public class GsonBuildConfigTest { +- +- @Test +- public void testEnsureGsonBuildConfigGetsUpdatedToMavenVersion() { +- assertFalse("${project.version}".equals(GsonBuildConfig.VERSION)); +- } +-} diff --git a/osgi-export-internal.patch b/osgi-export-internal.patch new file mode 100644 index 0000000..494578c --- /dev/null +++ b/osgi-export-internal.patch @@ -0,0 +1,25 @@ +From ad012fa6acc53560a07d05676aa22d1afc66bf22 Mon Sep 17 00:00:00 2001 +From: Mat Booth +Date: Thu, 27 Aug 2020 10:52:58 +0100 +Subject: [PATCH 2/4] Also export internal packages in OSGi metadata + +--- + gson/bnd.bnd | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/gson/bnd.bnd b/gson/bnd.bnd +index 7706d8a..8469930 100644 +--- a/gson/bnd.bnd ++++ b/gson/bnd.bnd +@@ -13,4 +13,7 @@ Import-Package: sun.misc;resolution:=optional,* + com.google.gson,\ + com.google.gson.annotations,\ + com.google.gson.reflect,\ +- com.google.gson.stream ++ com.google.gson.stream,\ ++ com.google.gson.internal;x-internal:=true,\ ++ com.google.gson.internal.bind;x-internal:=true,\ ++ com.google.gson.internal.bind.util;x-internal:=true +-- +2.26.2 +