From b6d43d7c39063b09fe40086a8c9228e656308c043fd72847d02c4e0e8733b5c3 Mon Sep 17 00:00:00 2001 From: Fridrich Strba Date: Tue, 6 Jun 2023 16:22:11 +0000 Subject: [PATCH] OBS-URL: https://build.opensuse.org/package/show/Java:packages/javassist?expand=0&rev=39 --- javassist-java8-compat.patch | 237 ++++++++++++++++++++++++++++++++--- javassist.changes | 9 ++ javassist.spec | 41 ++---- 3 files changed, 244 insertions(+), 43 deletions(-) diff --git a/javassist-java8-compat.patch b/javassist-java8-compat.patch index 7f21aa5..3f7020a 100644 --- a/javassist-java8-compat.patch +++ b/javassist-java8-compat.patch @@ -1,8 +1,130 @@ -Index: javassist-rel_3_28_0_ga/src/main/javassist/Loader.java -=================================================================== ---- javassist-rel_3_28_0_ga.orig/src/main/javassist/Loader.java -+++ javassist-rel_3_28_0_ga/src/main/javassist/Loader.java -@@ -421,9 +421,6 @@ public class Loader extends ClassLoader +--- a/src/main/javassist/ClassPool.java 2023-06-06 17:43:01.915579458 +0200 ++++ b/src/main/javassist/ClassPool.java 2023-06-06 18:01:26.034999321 +0200 +@@ -1141,59 +1141,6 @@ + * Once this method is called, further modifications are not allowed + * any more. + * +- *

This method is available in Java 9 or later. +- * It loads the class +- * by using {@code java.lang.invoke.MethodHandles} with {@code neighbor}. +- *

+- * +- * @param ct the class converted into {@code java.lang.Class}. +- * @param neighbor a class belonging to the same package that +- * the converted class belongs to. +- * @since 3.24 +- */ +- public Class toClass(CtClass ct, Class neighbor) +- throws CannotCompileException +- { +- try { +- return javassist.util.proxy.DefineClassHelper.toClass(neighbor, +- ct.toBytecode()); +- } +- catch (IOException e) { +- throw new CannotCompileException(e); +- } +- } +- +- /** +- * Converts the class to a java.lang.Class object. +- * Once this method is called, further modifications are not allowed +- * any more. +- * +- *

This method is available in Java 9 or later. +- * It loads the class +- * by using the given {@code java.lang.invoke.MethodHandles.Lookup}. +- *

+- * +- * @param ct the class converted into {@code java.lang.Class}. +- * @since 3.24 +- */ +- public Class toClass(CtClass ct, +- java.lang.invoke.MethodHandles.Lookup lookup) +- throws CannotCompileException +- { +- try { +- return javassist.util.proxy.DefineClassHelper.toClass(lookup, +- ct.toBytecode()); +- } +- catch (IOException e) { +- throw new CannotCompileException(e); +- } +- } +- +- /** +- * Converts the class to a java.lang.Class object. +- * Once this method is called, further modifications are not allowed +- * any more. +- * + *

When the JVM is Java 11 or later, this method loads the class + * by using {@code java.lang.invoke.MethodHandles} with {@code neighbor}. + * The other arguments {@code loader} and {@code domain} are not used; +--- a/src/main/javassist/CtClass.java 2023-06-06 17:43:01.915579458 +0200 ++++ b/src/main/javassist/CtClass.java 2023-06-06 18:02:41.811506992 +0200 +@@ -1300,59 +1300,6 @@ + + /** + * Converts this class to a java.lang.Class object. +- * Once this method is called, further modifications are not +- * allowed any more. +- * +- *

This method is provided for convenience. You should use +- * {@code toClass(Lookup)} for better compatibility with the +- * module system. +- * +- *

Note: this method calls toClass() +- * in ClassPool. +- * +- *

Warning: A Class object returned by this method may not +- * work with a security manager or a signed jar file because a +- * protection domain is not specified. +- * +- * @param neighbor A class belonging to the same package that this +- * class belongs to. It is used to load the class. +- * @see ClassPool#toClass(CtClass,Class) +- * @see #toClass(java.lang.invoke.MethodHandles.Lookup) +- * @since 3.24 +- */ +- public Class toClass(Class neighbor) throws CannotCompileException +- { +- return getClassPool().toClass(this, neighbor); +- } +- +- /** +- * Converts this class to a java.lang.Class object. +- * Once this method is called, further modifications are not +- * allowed any more. +- * +- *

This method is provided for convenience. If you need more +- * complex functionality, you should write your own class loader. +- * +- *

Note: this method calls toClass() +- * in ClassPool. +- * +- *

Warning: A Class object returned by this method may not +- * work with a security manager or a signed jar file because a +- * protection domain is not specified. +- * +- * @param lookup used when loading the class. It has to have +- * an access right to define a new class. +- * @see ClassPool#toClass(CtClass,java.lang.invoke.MethodHandles.Lookup) +- * @since 3.24 +- */ +- public Class toClass(java.lang.invoke.MethodHandles.Lookup lookup) +- throws CannotCompileException +- { +- return getClassPool().toClass(this, lookup); +- } +- +- /** +- * Converts this class to a java.lang.Class object. + * Once this method is called, further modifications are not allowed + * any more. + * +--- a/src/main/javassist/Loader.java 2023-06-06 17:43:01.923579511 +0200 ++++ b/src/main/javassist/Loader.java 2023-06-06 17:43:21.591712028 +0200 +@@ -421,9 +421,6 @@ } private boolean isDefinedPackage(String name) { @@ -12,14 +134,70 @@ Index: javassist-rel_3_28_0_ga/src/main/javassist/Loader.java return getPackage(name) == null; } -Index: javassist-rel_3_28_0_ga/src/main/javassist/util/proxy/DefineClassHelper.java -=================================================================== ---- javassist-rel_3_28_0_ga.orig/src/main/javassist/util/proxy/DefineClassHelper.java -+++ javassist-rel_3_28_0_ga/src/main/javassist/util/proxy/DefineClassHelper.java -@@ -317,23 +317,5 @@ public class DefineClassHelper { +--- a/src/main/javassist/util/proxy/DefineClassHelper.java 2023-06-06 17:43:01.979579888 +0200 ++++ b/src/main/javassist/util/proxy/DefineClassHelper.java 2023-06-06 17:56:53.241171849 +0200 +@@ -44,15 +44,11 @@ + ClassLoader loader, ProtectionDomain protectionDomain) + throws ClassFormatError, CannotCompileException + { +- if (neighbor != null) +- return toClass(neighbor, bcode); +- else { + // Lookup#defineClass() is not available. So fallback to invoking defineClass on + // ClassLoader, which causes a warning message. + return super.defineClass(name, bcode, off, len, neighbor, loader, protectionDomain); + } + } +- } + + private static class Java9 extends Helper { + final class ReferencedUnsafe { +@@ -275,65 +271,5 @@ } } +- +- /** +- * Loads a class file by {@code java.lang.invoke.MethodHandles.Lookup}. +- * It is obtained by using {@code neighbor}. +- * +- * @param neighbor a class belonging to the same package that the loaded +- * class belogns to. +- * @param bcode the bytecode. +- * @since 3.24 +- */ +- public static Class toClass(Class neighbor, byte[] bcode) +- throws CannotCompileException +- { +- try { +- DefineClassHelper.class.getModule().addReads(neighbor.getModule()); +- Lookup lookup = MethodHandles.lookup(); +- Lookup prvlookup = MethodHandles.privateLookupIn(neighbor, lookup); +- return prvlookup.defineClass(bcode); +- } catch (IllegalAccessException | IllegalArgumentException e) { +- throw new CannotCompileException(e.getMessage() + ": " + neighbor.getName() +- + " has no permission to define the class"); +- } +- } +- +- /** +- * Loads a class file by {@code java.lang.invoke.MethodHandles.Lookup}. +- * It can be obtained by {@code MethodHandles.lookup()} called from +- * somewhere in the package that the loaded class belongs to. +- * +- * @param bcode the bytecode. +- * @since 3.24 +- */ +- public static Class toClass(Lookup lookup, byte[] bcode) +- throws CannotCompileException +- { +- try { +- return lookup.defineClass(bcode); +- } catch (IllegalAccessException | IllegalArgumentException e) { +- throw new CannotCompileException(e.getMessage()); +- } +- } +- - /** - * Loads a class file by {@code java.lang.invoke.MethodHandles.Lookup}. - * @@ -40,11 +218,9 @@ Index: javassist-rel_3_28_0_ga/src/main/javassist/util/proxy/DefineClassHelper.j - private DefineClassHelper() {} } -Index: javassist-rel_3_28_0_ga/src/main/javassist/util/proxy/FactoryHelper.java -=================================================================== ---- javassist-rel_3_28_0_ga.orig/src/main/javassist/util/proxy/FactoryHelper.java -+++ javassist-rel_3_28_0_ga/src/main/javassist/util/proxy/FactoryHelper.java -@@ -148,11 +148,7 @@ public class FactoryHelper { +--- a/src/main/javassist/util/proxy/FactoryHelper.java 2023-06-06 17:43:01.979579888 +0200 ++++ b/src/main/javassist/util/proxy/FactoryHelper.java 2023-06-06 18:03:56.172005165 +0200 +@@ -148,29 +148,7 @@ { try { byte[] b = toBytecode(cf); @@ -53,7 +229,38 @@ Index: javassist-rel_3_28_0_ga/src/main/javassist/util/proxy/FactoryHelper.java - else - return DefineClassHelper.toClass(cf.getName(), neighbor, - loader, domain, b); +- } +- catch (IOException e) { +- throw new CannotCompileException(e); +- } +- } +- +- /** +- * Loads a class file by a given lookup. +- * +- * @param lookup used to define the class. +- * @since 3.24 +- */ +- public static Class toClass(ClassFile cf, java.lang.invoke.MethodHandles.Lookup lookup) +- throws CannotCompileException +- { +- try { +- byte[] b = toBytecode(cf); +- return DefineClassHelper.toClass(lookup, b); + return DefineClassHelper.toClass(cf.getName(), neighbor, loader, domain, b); } catch (IOException e) { throw new CannotCompileException(e); +--- a/src/main/javassist/util/proxy/ProxyFactory.java 2023-06-06 17:43:01.979579888 +0200 ++++ b/src/main/javassist/util/proxy/ProxyFactory.java 2023-06-06 18:05:06.452476007 +0200 +@@ -636,10 +636,7 @@ + if (writeDirectory != null) + FactoryHelper.writeFile(cf, writeDirectory); + +- if (lookup == null) + thisClass = FactoryHelper.toClass(cf, getClassInTheSamePackage(), cl, getDomain()); +- else +- thisClass = FactoryHelper.toClass(cf, lookup); + + setField(FILTER_SIGNATURE_FIELD, signature); + // legacy behaviour : we only set the default interceptor static field if we are not using the cache diff --git a/javassist.changes b/javassist.changes index c607ba1..2b5c5ef 100644 --- a/javassist.changes +++ b/javassist.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Tue Jun 6 16:20:35 UTC 2023 - Fridrich Strba + +- Clean up the spec file and make it actually build on a vanilla + SLE-12-SP5 +- Modified patch: + * javassist-java8-compat.patch + + make remove functions that are not available in java 8 + ------------------------------------------------------------------- Tue Sep 20 16:10:40 UTC 2022 - David Anes diff --git a/javassist.spec b/javassist.spec index 75e1f53..b91fb3b 100644 --- a/javassist.spec +++ b/javassist.spec @@ -1,7 +1,7 @@ # # spec file for package javassist # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # Copyright (c) 2000-2005, JPackage Project # # All modifications and additions to the file contributed by third parties @@ -30,6 +30,7 @@ Patch0: javassist-java8-compat.patch Patch1: javassist-osgi.patch BuildRequires: ant >= 1.6 BuildRequires: fdupes +BuildRequires: java-devel >= 1.8 BuildRequires: javapackages-local BuildArch: noarch @@ -76,13 +77,11 @@ Tutorial for javassist. %prep %setup -q -n %{name}-%{tar_version} -%if %{?pkg_vcmp:%pkg_vcmp java-devel < 9}%{!?pkg_vcmp:1} +%if %{!?pkg_vcmp:1}%{?pkg_vcmp:%pkg_vcmp java-devel < 9} %patch0 -p1 %endif %patch1 -p1 -for j in $(find . -name "*.jar"); do - mv $j $j.no -done +find . -name "*.jar" -print -delete %build ant -Dant.build.javac.source=1.8 -Dant.build.javac.target=1.8 dist @@ -90,14 +89,12 @@ ant -Dant.build.javac.source=1.8 -Dant.build.javac.target=1.8 dist %install # jars mkdir -p %{buildroot}/%{_javadir} -cp -p %{name}.jar \ - %{buildroot}/%{_javadir}/%{name}-%{version}.jar -(cd %{buildroot}/%{_javadir} && for jar in *-%{version}.jar; do ln -sf ${jar} `echo $jar| sed "s|-%{version}||g"`; done) +cp -p %{name}.jar %{buildroot}/%{_javadir}/%{name}.jar # pom install -d -m 755 %{buildroot}%{_mavenpomdir} -install -pm 644 pom.xml %{buildroot}%{_mavenpomdir}/%{name}.pom -%add_maven_depmap %{name}.pom %{name}.jar -a javassist:javassist +install -pm 644 pom.xml %{buildroot}%{_mavenpomdir}/JPP-%{name}.pom +%add_maven_depmap JPP-%{name}.pom %{name}.jar -a javassist:javassist # demo mkdir -p %{buildroot}/%{_datadir}/%{name}-%{version} @@ -107,35 +104,23 @@ cp -pr sample/* %{buildroot}/%{_datadir}/%{name}-%{version} mkdir -p %{buildroot}/%{_javadocdir}/%{name} cp -pr html/* %{buildroot}/%{_javadocdir}/%{name} -%fdupes -s %{buildroot}/%{_javadocdir}/%{name}/jquery/ +%fdupes -s %{buildroot}/%{_javadocdir}/%{name} # manual mkdir -p %{buildroot}/%{_docdir}/%{name}-%{version}/tutorial cp -pr tutorial/* %{buildroot}/%{_docdir}/%{name}-%{version}/tutorial -cp -p License.html %{buildroot}/%{_docdir}/%{name}-%{version} -%files -%defattr(0644,root,root,0755) -%dir %{_docdir}/%{name}-%{version} -%license %{_docdir}/%{name}-%{version}/License.html -%{_javadir}/*.jar -%{_mavenpomdir}/* -%if %{defined _maven_repository} -%{_mavendepmapfragdir}/%{name} -%else -%{_datadir}/maven-metadata/%{name}.xml* -%endif +%files -f .mfiles +%license License.html %files demo -%defattr(0644,root,root,0755) %{_datadir}/%{name}-%{version} %files javadoc -%defattr(0644,root,root,0755) -%doc %{_javadocdir}/%{name} +%{_javadocdir}/%{name} %files manual -%defattr(0644,root,root,0755) -%doc %{_docdir}/%{name}-%{version}/tutorial +%dir %{_docdir}/%{name}-%{version} +%{_docdir}/%{name}-%{version}/tutorial %changelog