Sync from SUSE:SLFO:Main javassist revision 21caf5a4d4494b1b085635722c839583

This commit is contained in:
Adrian Schröter 2024-05-03 13:58:30 +02:00
commit 94d88f9244
6 changed files with 659 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -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

View File

@ -0,0 +1,266 @@
--- 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.
*
- * <p>This method is available in Java 9 or later.
- * It loads the class
- * by using {@code java.lang.invoke.MethodHandles} with {@code neighbor}.
- * </p>
- *
- * @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 <code>java.lang.Class</code> object.
- * Once this method is called, further modifications are not allowed
- * any more.
- *
- * <p>This method is available in Java 9 or later.
- * It loads the class
- * by using the given {@code java.lang.invoke.MethodHandles.Lookup}.
- * </p>
- *
- * @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 <code>java.lang.Class</code> object.
- * Once this method is called, further modifications are not allowed
- * any more.
- *
* <p>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 <code>java.lang.Class</code> object.
- * Once this method is called, further modifications are not
- * allowed any more.
- *
- * <p>This method is provided for convenience. You should use
- * {@code toClass(Lookup)} for better compatibility with the
- * module system.
- *
- * <p>Note: this method calls <code>toClass()</code>
- * in <code>ClassPool</code>.
- *
- * <p><b>Warning:</b> 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 <code>java.lang.Class</code> object.
- * Once this method is called, further modifications are not
- * allowed any more.
- *
- * <p>This method is provided for convenience. If you need more
- * complex functionality, you should write your own class loader.
- *
- * <p>Note: this method calls <code>toClass()</code>
- * in <code>ClassPool</code>.
- *
- * <p><b>Warning:</b> 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 <code>java.lang.Class</code> 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) {
- if (ClassFile.MAJOR_VERSION >= ClassFile.JAVA_9)
- return getDefinedPackage(name) == null;
- else
return getPackage(name) == null;
}
--- 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}.
- *
- * @since 3.22
- */
- static Class<?> toPublicClass(String className, byte[] bcode)
- throws CannotCompileException
- {
- try {
- Lookup lookup = MethodHandles.lookup();
- lookup = lookup.dropLookupMode(java.lang.invoke.MethodHandles.Lookup.PRIVATE);
- return lookup.defineClass(bcode);
- }
- catch (Throwable t) {
- throw new CannotCompileException(t);
- }
- }
-
private DefineClassHelper() {}
}
--- 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);
- if (ProxyFactory.onlyPublicMethods)
- return DefineClassHelper.toPublicClass(cf.getName(), b);
- 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

53
javassist-osgi.patch Normal file
View File

@ -0,0 +1,53 @@
Index: javassist-rel_3_29_2_ga/src/main/META-INF/MANIFEST.MF
===================================================================
--- javassist-rel_3_29_2_ga.orig/src/main/META-INF/MANIFEST.MF
+++ javassist-rel_3_29_2_ga/src/main/META-INF/MANIFEST.MF
@@ -1 +1,48 @@
Automatic-Module-Name: org.javassist
+Bundle-Description: Javassist (JAVA programming ASSISTant)
+ makes Java bytecode manipulation simple. It is a class
+ library for editing bytecodes in Java.
+Bundle-License: http://www.mozilla.org/MPL/MPL-1.1.html,
+ http://www.gnu.org/licenses/lgpl-2.1.html,
+ http://www.apache.org/licenses/
+Bundle-ManifestVersion: 2
+Bundle-Name: Javassist
+Bundle-SymbolicName: javassist
+Bundle-Vendor: Shigeru Chiba, www.javassist.org
+Bundle-Version: 3.29.2.GA
+Export-Package: javassist;version="3.29.2.GA";
+ uses:="javassist.bytecode,javassist.compiler,
+ javassist.compiler.ast,javassist.convert,javassist.expr",
+ javassist.bytecode;version="3.29.2.GA";
+ uses:="javassist,javassist.bytecode.annotation",
+ javassist.bytecode.analysis;version="3.29.2.GA";
+ uses:="javassist,javassist.bytecode,javassist.bytecode.stackmap",
+ javassist.bytecode.annotation;version="3.29.2.GA";
+ uses:="javassist,javassist.bytecode",
+ javassist.bytecode.stackmap;version="3.29.2.GA";
+ uses:="javassist,javassist.bytecode",
+ javassist.compiler;version="3.29.2.GA";
+ uses:="javassist,javassist.bytecode,javassist.compiler.ast",
+ javassist.compiler.ast;version="3.29.2.GA";
+ uses:="javassist,javassist.compiler",
+ javassist.convert;version="3.29.2.GA";
+ uses:="javassist,javassist.bytecode",
+ javassist.expr;version="3.29.2.GA";
+ uses:="javassist,javassist.bytecode",
+ javassist.runtime;version="3.29.2.GA",
+ javassist.scopedpool;version="3.29.2.GA";
+ uses:=javassist,
+ javassist.tools;version="3.29.2.GA";
+ uses:=javassist,
+ javassist.tools.reflect;version="3.29.2.GA";
+ uses:="javassist,javassist.bytecode",
+ javassist.tools.rmi;version="3.29.2.GA";
+ uses:="javassist,javassist.tools.web",
+ javassist.tools.web;version="3.29.2.GA";
+ uses:=javassist,
+ javassist.util;version="3.29.2.GA";
+ uses:=javassist,
+ javassist.util.proxy;version="3.29.2.GA";
+ uses:="javassist,javassist.bytecode"
+Require-Capability: osgi.ee;
+ filter:="(&(osgi.ee=JavaSE)(version=1.7))"

188
javassist.changes Normal file
View File

@ -0,0 +1,188 @@
-------------------------------------------------------------------
Tue Jun 6 16:20:35 UTC 2023 - Fridrich Strba <fstrba@suse.com>
- 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 <david.anes@suse.com>
- Version update to 3.29.2:
* Include` Automatic-Module-Name in MANIFEST.MF
- Rebased javassist-osgi.patch and corrected version numbers in
the patch.
-------------------------------------------------------------------
Wed Aug 17 11:32:38 UTC 2022 - David Anes <david.anes@suse.com>
- Version update to 3.29.1:
* `Readme.html` was deleted.
- Rebased javassist-osgi.patch and corrected version numbers in
the patch.
-------------------------------------------------------------------
Mon May 23 13:16:59 UTC 2022 - David Anes <david.anes@suse.com>
- Requires java >= 1.8
- Rebased patches:
* javassist-osgi.patch
- Version update to 3.29.0:
* removes an unused import declaration as PR 384 mentions.
* Merge pull request #382 from tim-hoffman/PR_RemoveStringBuffer
* Merge pull request #383 from tim-hoffman/PR_ArrayCopyPerformance
* uncomments test code suggested by PR405
* cancels PR#391, which does not pass all the tests
* fixes a wrong indentation
* Merge pull request #391 from derklaro/fix-method-naming-syntax
* does refactoring
* fixes a bug in SignatureAttribute.renameClass().
* fixs a compilation problem although one test still fails.
* Merge pull request #299 from pietrobraione/master
* Merge branch 'master' into master
* Merge pull request #278 from ximsfei/master
* Merge pull request #390 from derklaro/master
* changes test code because package
java.rmi.activation.ActivationGroupDesc does not exist any
longer.
* deletes src/test/test2/*.class
* Merge pull request #399 from carldea/master
* Merge pull request #409 from aschleck/patch-1
* Remove redundant type check
* Using TCK Tested JDK builds of OpenJDK
* Merge pull request #395 from aburaksahin/master
* Fix for NullPointerException on detach()
* Only wrap the method name if the method doesn't come from the
same decl class
* Lower requirement for an extra type in constructor to Java 7-
* Replace array copy loop with System.arraycopy
* Replace remaining StringBuffer uses with StringBuilder
* Replace StringBuffer with StringBuilder and other minor String
optimizations
* fixes GitHub Issue 378 (wrong link for apache license)
* updates javassist.Loader to exclude jdk.internal.
* Fixes to support the full syntax of possible signatures
* Fix renaming of classes in presence of generic signatures and
nested classes.
* add unit test
* fixes a bug of ClassFile#renameClass(), some imports could not
be successfully renamed
-------------------------------------------------------------------
Fri Dec 10 18:51:02 UTC 2021 - David Anes <david.anes@suse.com>
- Rebased osgi patch: javassist-osgi.patch
- Rebased java8 compat patch: javassist-java8-compat.patch
- Requires Java API >= 1.7
-------------------------------------------------------------------
Wed Mar 25 14:07:34 UTC 2020 - Fridrich Strba <fstrba@suse.com>
- Added patch:
* javassist-osgi.patch
+ Add OSGi manifest to the javassist.jar
-------------------------------------------------------------------
Mon Apr 15 08:57:00 UTC 2019 - Fridrich Strba <fstrba@suse.com>
- Added patch:
* javassist-java8-compat.patch
- Allow building on systems that do not have java 9 or higher
-------------------------------------------------------------------
Thu Oct 18 11:32:34 UTC 2018 - Fridrich Strba <fstrba@suse.com>
- Install and package the maven pom and metadata files
-------------------------------------------------------------------
Mon Oct 15 14:53:58 UTC 2018 - Fridrich Strba <fstrba@suse.com>
- BuildRequire at least Java 9. This version uses APIs introduced
in Java 9
-------------------------------------------------------------------
Sun Oct 7 16:51:45 UTC 2018 - Jan Engelhardt <jengelh@inai.de>
- Replace old $RPM_* shell vars by macros.
-------------------------------------------------------------------
Fri Oct 5 13:19:12 UTC 2018 - pmonrealgonzalez@suse.com
- Version update to 3.23.1:
* 3.23.1 Github PR #171
* 3.23 Fix leaking file handlers in ClassPool and removed
ClassPath.close(). Github issue #165
* 3.22 Java 9 supports.
JIRA JASSIST-261.
- Dropped patch fixed upstream:
javassist-rel_3_21_0_ga-javadoc.patch
-------------------------------------------------------------------
Fri Sep 8 08:16:21 UTC 2017 - fstrba@suse.com
- Specify java target and source version 1.6 in order to allow
building with jdk9
- Added patch:
* javassist-rel_3_21_0_ga-javadoc.patch
- fix javadoc errors that are fatal with jdk9
-------------------------------------------------------------------
Fri Jun 9 10:14:10 UTC 2017 - tchvatal@suse.com
- Version update to 3.21.0:
* various compiler settings
* Require java >= 1.6
-------------------------------------------------------------------
Sat Jan 24 16:40:33 UTC 2015 - p.drouand@gmail.com
- Update to version 3.19.0
* Including a number of bug fixes and Java 8 supports.
- Clean up specfile
- Remove redundant %clean section
- Build for java API 1.5
- Remove unzip requirement
- Update home page and download source Urls
-------------------------------------------------------------------
Wed Sep 3 16:19:44 CEST 2014 - ro@suse.de
- fix group entries for subpackages
-------------------------------------------------------------------
Wed Sep 3 01:48:48 CEST 2014 - ro@suse.de
- sanitize release line in specfile
-------------------------------------------------------------------
Mon Sep 9 11:05:56 UTC 2013 - tchvatal@suse.com
- Move from jpackage-utils to javapackage-tools
-------------------------------------------------------------------
Thu Mar 7 16:51:50 UTC 2013 - cfarrell@suse.com
- license update: LGPL-2.1+ or MPL-1.1
This is a dual license so the operator is ^or^ not ^and^
-------------------------------------------------------------------
Tue Mar 5 13:17:51 UTC 2013 - coolo@suse.com
- update license to new format
-------------------------------------------------------------------
Fri Apr 27 10:03:44 UTC 2012 - mvyskocil@suse.cz
- format spec file for Factory
-------------------------------------------------------------------
Thu Dec 9 11:57:28 CET 2010 - mc@suse.de
- initial release

126
javassist.spec Normal file
View File

@ -0,0 +1,126 @@
#
# spec file for package javassist
#
# Copyright (c) 2023 SUSE LLC
# Copyright (c) 2000-2005, JPackage Project
#
# 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/
#
%define tar_version rel_3_29_2_ga
Name: javassist
Version: 3.29.2
Release: 0
Summary: Java Programming Assistant: bytecode manipulation
License: LGPL-2.1-or-later OR MPL-1.1
Group: Development/Libraries/Java
URL: https://www.javassist.org/
Source0: https://github.com/jboss-javassist/javassist/archive/%{tar_version}.tar.gz
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
%description
Javassist (Java Programming Assistant) makes Java bytecode manipulation
simple. It is a class library for editing bytecodes in Java; it enables
Java programs to define a new class at runtime and to modify a class
file when the JVM loads it. Unlike other similar bytecode editors,
Javassist provides two levels of API: source level and bytecode level.
If the users use the source-level API, they can edit a class file
without knowledge of the specifications of the Java bytecode. The whole
API is designed with only the vocabulary of the Java language. You can
even specify inserted bytecode in the form of source text; Javassist
compiles it on the fly. On the other hand, the bytecode-level API
allows the users to directly edit a class file as other editors.
%package demo
Summary: Samples for javassist
Group: Documentation/Other
Requires: javassist = %{version}-%{release}
%description demo
Samples for javassist.
%{summary}.
%package javadoc
Summary: Javadoc for javassist
Group: Documentation/HTML
%description javadoc
Javadoc for javassist.
%{summary}.
%package manual
Summary: Tutorial for javassist
Group: Documentation/Other
%description manual
Tutorial for javassist.
%{summary}.
%prep
%setup -q -n %{name}-%{tar_version}
%if %{!?pkg_vcmp:1}%{?pkg_vcmp:%pkg_vcmp java-devel < 9}
%patch0 -p1
%endif
%patch1 -p1
find . -name "*.jar" -print -delete
%build
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}.jar
# pom
install -d -m 755 %{buildroot}%{_mavenpomdir}
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}
cp -pr sample/* %{buildroot}/%{_datadir}/%{name}-%{version}
# javadoc
mkdir -p %{buildroot}/%{_javadocdir}/%{name}
cp -pr html/* %{buildroot}/%{_javadocdir}/%{name}
%fdupes -s %{buildroot}/%{_javadocdir}/%{name}
# manual
mkdir -p %{buildroot}/%{_docdir}/%{name}-%{version}/tutorial
cp -pr tutorial/* %{buildroot}/%{_docdir}/%{name}-%{version}/tutorial
%files -f .mfiles
%license License.html
%files demo
%{_datadir}/%{name}-%{version}
%files javadoc
%{_javadocdir}/%{name}
%files manual
%dir %{_docdir}/%{name}-%{version}
%{_docdir}/%{name}-%{version}/tutorial
%changelog

BIN
rel_3_29_2_ga.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.