Accepting request 959849 from Java:packages

4.20

OBS-URL: https://build.opensuse.org/request/show/959849
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/xbean?expand=0&rev=7
This commit is contained in:
Dominique Leuenberger 2022-03-07 16:47:18 +00:00 committed by Git OBS Bridge
commit 2e61607d0d
9 changed files with 183 additions and 793 deletions

View File

@ -1,35 +0,0 @@
From 5b1a0fe4400bffddd1ab31af91beaef7bb560f6c Mon Sep 17 00:00:00 2001
From: Michael Simacek <msimacek@redhat.com>
Date: Thu, 12 May 2016 11:40:13 +0200
Subject: [PATCH 1/3] Unshade ASM
---
.../org/apache/xbean/recipe/XbeanAsmParameterNameLoader.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/xbean-reflect/src/main/java/org/apache/xbean/recipe/XbeanAsmParameterNameLoader.java b/xbean-reflect/src/main/java/org/apache/xbean/recipe/XbeanAsmParameterNameLoader.java
index dea2f2a..303dfc3 100644
--- a/xbean-reflect/src/main/java/org/apache/xbean/recipe/XbeanAsmParameterNameLoader.java
+++ b/xbean-reflect/src/main/java/org/apache/xbean/recipe/XbeanAsmParameterNameLoader.java
@@ -17,12 +17,12 @@
*/
package org.apache.xbean.recipe;
-import org.apache.xbean.asm5.ClassReader;
-import org.apache.xbean.asm5.ClassVisitor;
-import org.apache.xbean.asm5.Label;
-import org.apache.xbean.asm5.MethodVisitor;
-import org.apache.xbean.asm5.Opcodes;
-import org.apache.xbean.asm5.Type;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
import java.io.IOException;
import java.io.InputStream;
--
2.9.3

42
0002-Unbundle-ASM.patch Normal file
View File

@ -0,0 +1,42 @@
From 4f7a61dcd47ed0dee2d78e31e2dd50b88ab42f25 Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Thu, 12 Dec 2019 08:51:57 +0100
Subject: [PATCH 2/3] Unbundle ASM
---
.../xbean/recipe/XbeanAsmParameterNameLoader.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/xbean-reflect/src/main/java/org/apache/xbean/recipe/XbeanAsmParameterNameLoader.java b/xbean-reflect/src/main/java/org/apache/xbean/recipe/XbeanAsmParameterNameLoader.java
index 20b646c..9e96775 100644
--- a/xbean-reflect/src/main/java/org/apache/xbean/recipe/XbeanAsmParameterNameLoader.java
+++ b/xbean-reflect/src/main/java/org/apache/xbean/recipe/XbeanAsmParameterNameLoader.java
@@ -17,11 +17,11 @@
*/
package org.apache.xbean.recipe;
-import org.apache.xbean.asm9.ClassReader;
-import org.apache.xbean.asm9.ClassVisitor;
-import org.apache.xbean.asm9.Label;
-import org.apache.xbean.asm9.MethodVisitor;
-import org.apache.xbean.asm9.Type;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Type;
import java.io.IOException;
import java.io.InputStream;
@@ -36,7 +36,7 @@ import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
-import static org.apache.xbean.asm9.shade.commons.AsmConstants.ASM_VERSION;
+import static org.apache.xbean.asm9.original.commons.AsmConstants.ASM_VERSION;
/**
* Implementation of ParameterNameLoader that uses ASM to read the parameter names from the local variable table in the
--
2.29.2

View File

@ -1,689 +0,0 @@
From 928bd5a98dc500a31197a56c8f6c5e19a3a273f8 Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Fri, 21 Nov 2014 10:51:38 +0100
Subject: [PATCH 3/3] Port to QDox 2.0
---
pom.xml | 2 +-
.../blueprint/generator/QdoxMappingLoader.java | 144 +++++++++++---------
.../xbean/spring/generator/QdoxMappingLoader.java | 148 ++++++++++++---------
.../org/apache/xbean/spring/generator/Type.java | 7 +-
4 files changed, 166 insertions(+), 135 deletions(-)
diff --git a/pom.xml b/pom.xml
index 6e53649..9132fe4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -297,7 +297,7 @@
<dependency>
<groupId>com.thoughtworks.qdox</groupId>
<artifactId>qdox</artifactId>
- <version>1.6.3</version>
+ <version>2.0-M5</version>
</dependency>
<dependency>
diff --git a/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/QdoxMappingLoader.java b/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/QdoxMappingLoader.java
index 6635937..e17fd08 100644
--- a/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/QdoxMappingLoader.java
+++ b/xbean-blueprint/src/main/java/org/apache/xbean/blueprint/generator/QdoxMappingLoader.java
@@ -20,6 +20,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
@@ -31,14 +32,17 @@ import java.util.TreeSet;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
-import com.thoughtworks.qdox.JavaDocBuilder;
+import com.thoughtworks.qdox.JavaProjectBuilder;
import com.thoughtworks.qdox.model.BeanProperty;
import com.thoughtworks.qdox.model.DocletTag;
import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaConstructor;
import com.thoughtworks.qdox.model.JavaMethod;
+import com.thoughtworks.qdox.model.JavaModel;
import com.thoughtworks.qdox.model.JavaParameter;
import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.model.Type;
+import com.thoughtworks.qdox.model.JavaType;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -62,7 +66,7 @@ public class QdoxMappingLoader implements MappingLoader {
private final String defaultNamespace;
private final File[] srcDirs;
private final String[] excludedClasses;
- private Type collectionType;
+ private JavaClass collectionType;
public QdoxMappingLoader(String defaultNamespace, File[] srcDirs, String[] excludedClasses) {
this.defaultNamespace = defaultNamespace;
@@ -79,7 +83,7 @@ public class QdoxMappingLoader implements MappingLoader {
}
public Set<NamespaceMapping> loadNamespaces() throws IOException {
- JavaDocBuilder builder = new JavaDocBuilder();
+ JavaProjectBuilder builder = new JavaProjectBuilder();
log.debug("Source directories: ");
@@ -92,11 +96,11 @@ public class QdoxMappingLoader implements MappingLoader {
getSourceFiles(sourceDirectory, excludedClasses, builder);
}
- collectionType = builder.getClassByName("java.util.Collection").asType();
+ collectionType = builder.getClassByName("java.util.Collection");
return loadNamespaces(builder);
}
- private Set<NamespaceMapping> loadNamespaces(JavaDocBuilder builder) {
+ private Set<NamespaceMapping> loadNamespaces(JavaProjectBuilder builder) {
// load all of the elements
List<ElementMapping> elements = loadElements(builder);
@@ -131,14 +135,14 @@ public class QdoxMappingLoader implements MappingLoader {
return Collections.unmodifiableSet(namespaces);
}
- private List<ElementMapping> loadElements(JavaDocBuilder builder) {
- JavaSource[] javaSources = builder.getSources();
+ private List<ElementMapping> loadElements(JavaProjectBuilder builder) {
+ Collection<JavaSource> javaSources = builder.getSources();
List<ElementMapping> elements = new ArrayList<ElementMapping>();
for (JavaSource javaSource : javaSources) {
- if (javaSource.getClasses().length == 0) {
+ if (javaSource.getClasses().isEmpty()) {
log.info("No Java Classes defined in: " + javaSource.getURL());
} else {
- JavaClass[] classes = javaSource.getClasses();
+ Collection<JavaClass> classes = javaSource.getClasses();
for (JavaClass javaClass : classes) {
ElementMapping element = loadElement(builder, javaClass);
if (element != null && !javaClass.isAbstract()) {
@@ -152,7 +156,7 @@ public class QdoxMappingLoader implements MappingLoader {
return elements;
}
- private ElementMapping loadElement(JavaDocBuilder builder, JavaClass javaClass) {
+ private ElementMapping loadElement(JavaProjectBuilder builder, JavaClass javaClass) {
DocletTag xbeanTag = javaClass.getTagByName(XBEAN_ANNOTATION);
if (xbeanTag == null) {
return null;
@@ -176,7 +180,7 @@ public class QdoxMappingLoader implements MappingLoader {
Map<String, AttributeMapping> attributesByPropertyName = new HashMap<String, AttributeMapping>();
for (JavaClass jClass = javaClass; jClass != null; jClass = jClass.getSuperJavaClass()) {
- BeanProperty[] beanProperties = jClass.getBeanProperties();
+ Collection<BeanProperty> beanProperties = jClass.getBeanProperties();
for (BeanProperty beanProperty : beanProperties) {
// we only care about properties with a setter
if (beanProperty.getMutator() != null) {
@@ -219,9 +223,9 @@ public class QdoxMappingLoader implements MappingLoader {
String destroyMethod = null;
String factoryMethod = null;
for (JavaClass jClass = javaClass; jClass != null; jClass = jClass.getSuperJavaClass()) {
- JavaMethod[] methods = javaClass.getMethods();
+ Collection<JavaMethod> methods = javaClass.getMethods();
for (JavaMethod method : methods) {
- if (method.isPublic() && !method.isConstructor()) {
+ if (method.isPublic()) {
if (initMethod == null && method.getTagByName(INIT_METHOD_ANNOTATION) != null) {
initMethod = method.getName();
}
@@ -237,22 +241,43 @@ public class QdoxMappingLoader implements MappingLoader {
}
List<List<ParameterMapping>> constructorArgs = new ArrayList<List<ParameterMapping>>();
- JavaMethod[] methods = javaClass.getMethods();
- for (JavaMethod method : methods) {
- JavaParameter[] parameters = method.getParameters();
- if (isValidConstructor(factoryMethod, method, parameters)) {
- List<ParameterMapping> args = new ArrayList<ParameterMapping>(parameters.length);
- for (JavaParameter parameter : parameters) {
- AttributeMapping attributeMapping = attributesByPropertyName.get(parameter.getName());
- if (attributeMapping == null) {
- attributeMapping = loadParameter(parameter);
-
- attributes.add(attributeMapping);
- attributesByPropertyName.put(attributeMapping.getPropertyName(), attributeMapping);
+ if (factoryMethod == null) {
+ Collection<JavaConstructor> constructors = javaClass.getConstructors();
+ for (JavaConstructor constructor : constructors) {
+ Collection<JavaParameter> parameters = constructor.getParameters();
+ if (constructor.isPublic() && parameters.size() > 0) {
+ List<ParameterMapping> args = new ArrayList<ParameterMapping>(parameters.size());
+ for (JavaParameter parameter : parameters) {
+ AttributeMapping attributeMapping = attributesByPropertyName.get(parameter.getName());
+ if (attributeMapping == null) {
+ attributeMapping = loadParameter(parameter, constructor);
+
+ attributes.add(attributeMapping);
+ attributesByPropertyName.put(attributeMapping.getPropertyName(), attributeMapping);
+ }
+ args.add(new ParameterMapping(attributeMapping.getPropertyName(), toMappingType(parameter.getType(), null)));
}
- args.add(new ParameterMapping(attributeMapping.getPropertyName(), toMappingType(parameter.getType(), null)));
+ constructorArgs.add(Collections.unmodifiableList(args));
+ }
+ }
+ } else {
+ Collection<JavaMethod> methods = javaClass.getMethods();
+ for (JavaMethod method : methods) {
+ Collection<JavaParameter> parameters = method.getParameters();
+ if (method.isPublic() && parameters.size() > 0 && method.getName().equals(factoryMethod)) {
+ List<ParameterMapping> args = new ArrayList<ParameterMapping>(parameters.size());
+ for (JavaParameter parameter : parameters) {
+ AttributeMapping attributeMapping = attributesByPropertyName.get(parameter.getName());
+ if (attributeMapping == null) {
+ attributeMapping = loadParameter(parameter, method);
+
+ attributes.add(attributeMapping);
+ attributesByPropertyName.put(attributeMapping.getPropertyName(), attributeMapping);
+ }
+ args.add(new ParameterMapping(attributeMapping.getPropertyName(), toMappingType(parameter.getType(), null)));
+ }
+ constructorArgs.add(Collections.unmodifiableList(args));
}
- constructorArgs.add(Collections.unmodifiableList(args));
}
}
@@ -303,7 +328,7 @@ public class QdoxMappingLoader implements MappingLoader {
interfaces);
}
- private List<String> getFullyQualifiedNames(JavaClass[] implementedInterfaces) {
+ private List<String> getFullyQualifiedNames(Collection<JavaClass> implementedInterfaces) {
ArrayList<String> l = new ArrayList<String>();
for (JavaClass implementedInterface : implementedInterfaces) {
l.add(implementedInterface.getFullyQualifiedName());
@@ -395,19 +420,19 @@ public class QdoxMappingLoader implements MappingLoader {
return defaultDescription;
}
- private AttributeMapping loadParameter(JavaParameter parameter) {
+ private AttributeMapping loadParameter(JavaParameter parameter, JavaModel methodOrConstructor) {
String parameterName = parameter.getName();
String parameterDescription = getParameterDescription(parameter);
// first attempt to load the attribute from the java beans accessor methods
- JavaClass javaClass = parameter.getParentMethod().getParentClass();
+ JavaClass javaClass = parameter.getParentClass();
BeanProperty beanProperty = javaClass.getBeanProperty(parameterName);
if (beanProperty != null) {
AttributeMapping attributeMapping = loadAttribute(beanProperty, parameterDescription);
// if the attribute mapping is null, the property was tagged as hidden and this is an error
if (attributeMapping == null) {
throw new InvalidModelException("Hidden property usage: " +
- "The construction method " + toMethodLocator(parameter.getParentMethod()) +
+ "The construction method " + toMethodLocator(parameter.getParentClass(), methodOrConstructor) +
" can not use a hidded property " + parameterName);
}
return attributeMapping;
@@ -426,9 +451,9 @@ public class QdoxMappingLoader implements MappingLoader {
private String getParameterDescription(JavaParameter parameter) {
String parameterName = parameter.getName();
- DocletTag[] tags = parameter.getParentMethod().getTagsByName("param");
+ Collection<DocletTag> tags = parameter.getTagsByName("param");
for (DocletTag tag : tags) {
- if (tag.getParameters()[0].equals(parameterName)) {
+ if (tag.getParameters().get(0).equals(parameterName)) {
String parameterDescription = tag.getValue().trim();
if (parameterDescription.startsWith(parameterName)) {
parameterDescription = parameterDescription.substring(parameterName.length()).trim();
@@ -439,18 +464,6 @@ public class QdoxMappingLoader implements MappingLoader {
return null;
}
- private boolean isValidConstructor(String factoryMethod, JavaMethod method, JavaParameter[] parameters) {
- if (!method.isPublic() || parameters.length == 0) {
- return false;
- }
-
- if (factoryMethod == null) {
- return method.isConstructor();
- } else {
- return method.getName().equals(factoryMethod);
- }
- }
-
private static String getProperty(DocletTag propertyTag, String propertyName) {
return getProperty(propertyTag, propertyName, null);
}
@@ -477,14 +490,17 @@ public class QdoxMappingLoader implements MappingLoader {
return false;
}
- private org.apache.xbean.blueprint.generator.Type toMappingType(Type type, String nestedType) {
+ private org.apache.xbean.blueprint.generator.Type toMappingType(JavaType type, String nestedType) {
try {
- if (type.isArray()) {
- return org.apache.xbean.blueprint.generator.Type.newArrayType(type.getValue(), type.getDimensions());
- } else if (type.isA(collectionType)) {
- if (nestedType == null) nestedType = "java.lang.Object";
- return org.apache.xbean.blueprint.generator.Type.newCollectionType(type.getValue(),
- org.apache.xbean.blueprint.generator.Type.newSimpleType(nestedType));
+ if (type instanceof JavaClass) {
+ JavaClass clazz = (JavaClass)type;
+ if (clazz.isArray()) {
+ return org.apache.xbean.blueprint.generator.Type.newArrayType(type.getValue(), clazz.getDimensions());
+ } else if (clazz.isA(collectionType)) {
+ if (nestedType == null) nestedType = "java.lang.Object";
+ return org.apache.xbean.blueprint.generator.Type.newCollectionType(type.getValue(),
+ org.apache.xbean.blueprint.generator.Type.newSimpleType(nestedType));
+ }
}
} catch (Throwable t) {
log.debug("Could not load type mapping", t);
@@ -492,26 +508,28 @@ public class QdoxMappingLoader implements MappingLoader {
return org.apache.xbean.blueprint.generator.Type.newSimpleType(type.getValue());
}
- private static String toMethodLocator(JavaMethod method) {
+ private static String toMethodLocator(JavaClass parentClass, JavaModel methodOrConstructor) {
+ JavaMethod method = methodOrConstructor instanceof JavaMethod ? (JavaMethod) methodOrConstructor : null;
+ JavaConstructor constructor = methodOrConstructor instanceof JavaConstructor ? (JavaConstructor) methodOrConstructor : null;
StringBuffer buf = new StringBuffer();
- buf.append(method.getParentClass().getFullyQualifiedName());
- if (!method.isConstructor()) {
+ buf.append(parentClass.getFullyQualifiedName());
+ if (method != null) {
buf.append(".").append(method.getName());
}
buf.append("(");
- JavaParameter[] parameters = method.getParameters();
- for (int i = 0; i < parameters.length; i++) {
- JavaParameter parameter = parameters[i];
+ List<JavaParameter> parameters = method != null ? method.getParameters() : constructor.getParameters();
+ for (int i = 0; i < parameters.size(); i++) {
+ JavaParameter parameter = parameters.get(i);
if (i > 0) {
buf.append(", ");
}
buf.append(parameter.getName());
}
- buf.append(") : ").append(method.getLineNumber());
+ buf.append(") : ").append(method != null ? method.getLineNumber() : constructor.getLineNumber());
return buf.toString();
}
- private static void getSourceFiles(File base, String[] excludedClasses, JavaDocBuilder builder) throws IOException {
+ private static void getSourceFiles(File base, String[] excludedClasses, JavaProjectBuilder builder) throws IOException {
if (base.isDirectory()) {
listAllFileNames(base, "", excludedClasses, builder);
} else {
@@ -519,7 +537,7 @@ public class QdoxMappingLoader implements MappingLoader {
}
}
- private static void listAllFileNames(File base, String prefix, String[] excludedClasses, JavaDocBuilder builder) throws IOException {
+ private static void listAllFileNames(File base, String prefix, String[] excludedClasses, JavaProjectBuilder builder) throws IOException {
if (!base.canRead() || !base.isDirectory()) {
throw new IllegalArgumentException(base.getAbsolutePath());
}
@@ -536,7 +554,7 @@ public class QdoxMappingLoader implements MappingLoader {
}
}
- private static void listAllJarEntries(File base, String[] excludedClasses, JavaDocBuilder builder) throws IOException {
+ private static void listAllJarEntries(File base, String[] excludedClasses, JavaProjectBuilder builder) throws IOException {
JarFile jarFile = new JarFile(base);
for (Enumeration entries = jarFile.entries(); entries.hasMoreElements(); ) {
JarEntry entry = (JarEntry) entries.nextElement();
diff --git a/xbean-spring/src/main/java/org/apache/xbean/spring/generator/QdoxMappingLoader.java b/xbean-spring/src/main/java/org/apache/xbean/spring/generator/QdoxMappingLoader.java
index 94bd7a1..228117e 100644
--- a/xbean-spring/src/main/java/org/apache/xbean/spring/generator/QdoxMappingLoader.java
+++ b/xbean-spring/src/main/java/org/apache/xbean/spring/generator/QdoxMappingLoader.java
@@ -20,6 +20,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
@@ -31,14 +32,17 @@ import java.util.TreeSet;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
-import com.thoughtworks.qdox.JavaDocBuilder;
+import com.thoughtworks.qdox.JavaProjectBuilder;
import com.thoughtworks.qdox.model.BeanProperty;
import com.thoughtworks.qdox.model.DocletTag;
import com.thoughtworks.qdox.model.JavaClass;
+import com.thoughtworks.qdox.model.JavaConstructor;
import com.thoughtworks.qdox.model.JavaMethod;
+import com.thoughtworks.qdox.model.JavaModel;
import com.thoughtworks.qdox.model.JavaParameter;
import com.thoughtworks.qdox.model.JavaSource;
-import com.thoughtworks.qdox.model.Type;
+import com.thoughtworks.qdox.model.JavaType;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -62,7 +66,7 @@ public class QdoxMappingLoader implements MappingLoader {
private final String defaultNamespace;
private final File[] srcDirs;
private final String[] excludedClasses;
- private Type collectionType;
+ private JavaClass collectionType;
public QdoxMappingLoader(String defaultNamespace, File[] srcDirs, String[] excludedClasses) {
this.defaultNamespace = defaultNamespace;
@@ -79,7 +83,7 @@ public class QdoxMappingLoader implements MappingLoader {
}
public Set<NamespaceMapping> loadNamespaces() throws IOException {
- JavaDocBuilder builder = new JavaDocBuilder();
+ JavaProjectBuilder builder = new JavaProjectBuilder();
log.debug("Source directories: ");
@@ -92,11 +96,11 @@ public class QdoxMappingLoader implements MappingLoader {
getSourceFiles(sourceDirectory, excludedClasses, builder);
}
- collectionType = builder.getClassByName("java.util.Collection").asType();
+ collectionType = builder.getClassByName("java.util.Collection");
return loadNamespaces(builder);
}
- private Set<NamespaceMapping> loadNamespaces(JavaDocBuilder builder) {
+ private Set<NamespaceMapping> loadNamespaces(JavaProjectBuilder builder) {
// load all of the elements
List<ElementMapping> elements = loadElements(builder);
@@ -131,14 +135,14 @@ public class QdoxMappingLoader implements MappingLoader {
return Collections.unmodifiableSet(namespaces);
}
- private List<ElementMapping> loadElements(JavaDocBuilder builder) {
- JavaSource[] javaSources = builder.getSources();
+ private List<ElementMapping> loadElements(JavaProjectBuilder builder) {
+ Collection<JavaSource> javaSources = builder.getSources();
List<ElementMapping> elements = new ArrayList<ElementMapping>();
for (JavaSource javaSource : javaSources) {
- if (javaSource.getClasses().length == 0) {
+ if (javaSource.getClasses().isEmpty()) {
log.info("No Java Classes defined in: " + javaSource.getURL());
} else {
- JavaClass[] classes = javaSource.getClasses();
+ Collection<JavaClass> classes = javaSource.getClasses();
for (JavaClass javaClass : classes) {
ElementMapping element = loadElement(builder, javaClass);
if (element != null && !javaClass.isAbstract()) {
@@ -152,7 +156,7 @@ public class QdoxMappingLoader implements MappingLoader {
return elements;
}
- private ElementMapping loadElement(JavaDocBuilder builder, JavaClass javaClass) {
+ private ElementMapping loadElement(JavaProjectBuilder builder, JavaClass javaClass) {
DocletTag xbeanTag = javaClass.getTagByName(XBEAN_ANNOTATION);
if (xbeanTag == null) {
return null;
@@ -176,7 +180,7 @@ public class QdoxMappingLoader implements MappingLoader {
Map<String, AttributeMapping> attributesByPropertyName = new HashMap<String, AttributeMapping>();
for (JavaClass jClass = javaClass; jClass != null; jClass = jClass.getSuperJavaClass()) {
- BeanProperty[] beanProperties = jClass.getBeanProperties();
+ Collection<BeanProperty> beanProperties = jClass.getBeanProperties();
for (BeanProperty beanProperty : beanProperties) {
// we only care about properties with a setter
if (beanProperty.getMutator() != null) {
@@ -219,9 +223,9 @@ public class QdoxMappingLoader implements MappingLoader {
String destroyMethod = null;
String factoryMethod = null;
for (JavaClass jClass = javaClass; jClass != null; jClass = jClass.getSuperJavaClass()) {
- JavaMethod[] methods = javaClass.getMethods();
+ Collection<JavaMethod> methods = javaClass.getMethods();
for (JavaMethod method : methods) {
- if (method.isPublic() && !method.isConstructor()) {
+ if (method.isPublic()) {
if (initMethod == null && method.getTagByName(INIT_METHOD_ANNOTATION) != null) {
initMethod = method.getName();
}
@@ -237,27 +241,48 @@ public class QdoxMappingLoader implements MappingLoader {
}
List<List<ParameterMapping>> constructorArgs = new ArrayList<List<ParameterMapping>>();
- JavaMethod[] methods = javaClass.getMethods();
- for (JavaMethod method : methods) {
- JavaParameter[] parameters = method.getParameters();
- if (isValidConstructor(factoryMethod, method, parameters)) {
- List<ParameterMapping> args = new ArrayList<ParameterMapping>(parameters.length);
- for (JavaParameter parameter : parameters) {
- AttributeMapping attributeMapping = attributesByPropertyName.get(parameter.getName());
- if (attributeMapping == null) {
- attributeMapping = loadParameter(parameter);
-
- attributes.add(attributeMapping);
- attributesByPropertyName.put(attributeMapping.getPropertyName(), attributeMapping);
+ if (factoryMethod == null) {
+ Collection<JavaConstructor> constructors = javaClass.getConstructors();
+ for (JavaConstructor constructor : constructors) {
+ Collection<JavaParameter> parameters = constructor.getParameters();
+ if (constructor.isPublic() && parameters.size() > 0) {
+ List<ParameterMapping> args = new ArrayList<ParameterMapping>(parameters.size());
+ for (JavaParameter parameter : parameters) {
+ AttributeMapping attributeMapping = attributesByPropertyName.get(parameter.getName());
+ if (attributeMapping == null) {
+ attributeMapping = loadParameter(parameter, constructor);
+
+ attributes.add(attributeMapping);
+ attributesByPropertyName.put(attributeMapping.getPropertyName(), attributeMapping);
+ }
+ args.add(new ParameterMapping(attributeMapping.getPropertyName(), toMappingType(parameter.getType(), null)));
}
- args.add(new ParameterMapping(attributeMapping.getPropertyName(), toMappingType(parameter.getType(), null)));
+ constructorArgs.add(Collections.unmodifiableList(args));
+ }
+ }
+ } else {
+ Collection<JavaMethod> methods = javaClass.getMethods();
+ for (JavaMethod method : methods) {
+ Collection<JavaParameter> parameters = method.getParameters();
+ if (method.isPublic() && parameters.size() > 0 && method.getName().equals(factoryMethod)) {
+ List<ParameterMapping> args = new ArrayList<ParameterMapping>(parameters.size());
+ for (JavaParameter parameter : parameters) {
+ AttributeMapping attributeMapping = attributesByPropertyName.get(parameter.getName());
+ if (attributeMapping == null) {
+ attributeMapping = loadParameter(parameter, method);
+
+ attributes.add(attributeMapping);
+ attributesByPropertyName.put(attributeMapping.getPropertyName(), attributeMapping);
+ }
+ args.add(new ParameterMapping(attributeMapping.getPropertyName(), toMappingType(parameter.getType(), null)));
+ }
+ constructorArgs.add(Collections.unmodifiableList(args));
}
- constructorArgs.add(Collections.unmodifiableList(args));
}
}
HashSet<String> interfaces = new HashSet<String>();
- interfaces.addAll(getFullyQualifiedNames(javaClass.getImplementedInterfaces()));
+ interfaces.addAll(getFullyQualifiedNames(javaClass.getInterfaces()));
JavaClass actualClass = javaClass;
if (factoryClass != null) {
@@ -282,7 +307,7 @@ public class QdoxMappingLoader implements MappingLoader {
}
p = s;
superClasses.add(p.getFullyQualifiedName());
- interfaces.addAll(getFullyQualifiedNames(p.getImplementedInterfaces()));
+ interfaces.addAll(getFullyQualifiedNames(p.getInterfaces()));
}
return new ElementMapping(namespace,
@@ -303,7 +328,7 @@ public class QdoxMappingLoader implements MappingLoader {
interfaces);
}
- private List<String> getFullyQualifiedNames(JavaClass[] implementedInterfaces) {
+ private List<String> getFullyQualifiedNames(Collection<JavaClass> implementedInterfaces) {
ArrayList<String> l = new ArrayList<String>();
for (JavaClass implementedInterface : implementedInterfaces) {
l.add(implementedInterface.getFullyQualifiedName());
@@ -395,19 +420,19 @@ public class QdoxMappingLoader implements MappingLoader {
return defaultDescription;
}
- private AttributeMapping loadParameter(JavaParameter parameter) {
+ private AttributeMapping loadParameter(JavaParameter parameter, JavaModel methodOrConstructor) {
String parameterName = parameter.getName();
String parameterDescription = getParameterDescription(parameter);
// first attempt to load the attribute from the java beans accessor methods
- JavaClass javaClass = parameter.getParentMethod().getParentClass();
+ JavaClass javaClass = parameter.getDeclaringClass();
BeanProperty beanProperty = javaClass.getBeanProperty(parameterName);
if (beanProperty != null) {
AttributeMapping attributeMapping = loadAttribute(beanProperty, parameterDescription);
// if the attribute mapping is null, the property was tagged as hidden and this is an error
if (attributeMapping == null) {
throw new InvalidModelException("Hidden property usage: " +
- "The construction method " + toMethodLocator(parameter.getParentMethod()) +
+ "The construction method " + toMethodLocator(parameter.getDeclaringClass(), methodOrConstructor) +
" can not use a hidded property " + parameterName);
}
return attributeMapping;
@@ -426,9 +451,9 @@ public class QdoxMappingLoader implements MappingLoader {
private String getParameterDescription(JavaParameter parameter) {
String parameterName = parameter.getName();
- DocletTag[] tags = parameter.getParentMethod().getTagsByName("param");
+ Collection<DocletTag> tags = parameter.getTagsByName("param");
for (DocletTag tag : tags) {
- if (tag.getParameters()[0].equals(parameterName)) {
+ if (tag.getParameters().get(0).equals(parameterName)) {
String parameterDescription = tag.getValue().trim();
if (parameterDescription.startsWith(parameterName)) {
parameterDescription = parameterDescription.substring(parameterName.length()).trim();
@@ -439,18 +464,6 @@ public class QdoxMappingLoader implements MappingLoader {
return null;
}
- private boolean isValidConstructor(String factoryMethod, JavaMethod method, JavaParameter[] parameters) {
- if (!method.isPublic() || parameters.length == 0) {
- return false;
- }
-
- if (factoryMethod == null) {
- return method.isConstructor();
- } else {
- return method.getName().equals(factoryMethod);
- }
- }
-
private static String getProperty(DocletTag propertyTag, String propertyName) {
return getProperty(propertyTag, propertyName, null);
}
@@ -477,14 +490,17 @@ public class QdoxMappingLoader implements MappingLoader {
return false;
}
- private org.apache.xbean.spring.generator.Type toMappingType(Type type, String nestedType) {
+ private org.apache.xbean.spring.generator.Type toMappingType(JavaType type, String nestedType) {
try {
- if (type.isArray()) {
- return org.apache.xbean.spring.generator.Type.newArrayType(type.getValue(), type.getDimensions());
- } else if (type.isA(collectionType)) {
- if (nestedType == null) nestedType = "java.lang.Object";
- return org.apache.xbean.spring.generator.Type.newCollectionType(type.getValue(),
- org.apache.xbean.spring.generator.Type.newSimpleType(nestedType));
+ if (type instanceof JavaClass) {
+ JavaClass clazz = (JavaClass)type;
+ if (clazz.isArray()) {
+ return org.apache.xbean.spring.generator.Type.newArrayType(type.getValue(), clazz.getDimensions());
+ } else if (clazz.isA(collectionType)) {
+ if (nestedType == null) nestedType = "java.lang.Object";
+ return org.apache.xbean.spring.generator.Type.newCollectionType(type.getValue(),
+ org.apache.xbean.spring.generator.Type.newSimpleType(nestedType));
+ }
}
} catch (Throwable t) {
log.debug("Could not load type mapping", t);
@@ -492,26 +508,28 @@ public class QdoxMappingLoader implements MappingLoader {
return org.apache.xbean.spring.generator.Type.newSimpleType(type.getValue());
}
- private static String toMethodLocator(JavaMethod method) {
+ private static String toMethodLocator(JavaClass parentClass, JavaModel methodOrConstructor) {
+ JavaMethod method = methodOrConstructor instanceof JavaMethod ? (JavaMethod) methodOrConstructor : null;
+ JavaConstructor constructor = methodOrConstructor instanceof JavaConstructor ? (JavaConstructor) methodOrConstructor : null;
StringBuffer buf = new StringBuffer();
- buf.append(method.getParentClass().getFullyQualifiedName());
- if (!method.isConstructor()) {
+ buf.append(parentClass.getFullyQualifiedName());
+ if (method != null) {
buf.append(".").append(method.getName());
}
buf.append("(");
- JavaParameter[] parameters = method.getParameters();
- for (int i = 0; i < parameters.length; i++) {
- JavaParameter parameter = parameters[i];
+ List<JavaParameter> parameters = method != null ? method.getParameters() : constructor.getParameters();
+ for (int i = 0; i < parameters.size(); i++) {
+ JavaParameter parameter = parameters.get(i);
if (i > 0) {
buf.append(", ");
}
buf.append(parameter.getName());
}
- buf.append(") : ").append(method.getLineNumber());
+ buf.append(") : ").append(method != null ? method.getLineNumber() : constructor.getLineNumber());
return buf.toString();
}
- private static void getSourceFiles(File base, String[] excludedClasses, JavaDocBuilder builder) throws IOException {
+ private static void getSourceFiles(File base, String[] excludedClasses, JavaProjectBuilder builder) throws IOException {
if (base.isDirectory()) {
listAllFileNames(base, "", excludedClasses, builder);
} else {
@@ -519,7 +537,7 @@ public class QdoxMappingLoader implements MappingLoader {
}
}
- private static void listAllFileNames(File base, String prefix, String[] excludedClasses, JavaDocBuilder builder) throws IOException {
+ private static void listAllFileNames(File base, String prefix, String[] excludedClasses, JavaProjectBuilder builder) throws IOException {
if (!base.canRead() || !base.isDirectory()) {
throw new IllegalArgumentException(base.getAbsolutePath());
}
@@ -536,7 +554,7 @@ public class QdoxMappingLoader implements MappingLoader {
}
}
- private static void listAllJarEntries(File base, String[] excludedClasses, JavaDocBuilder builder) throws IOException {
+ private static void listAllJarEntries(File base, String[] excludedClasses, JavaProjectBuilder builder) throws IOException {
JarFile jarFile = new JarFile(base);
for (Enumeration entries = jarFile.entries(); entries.hasMoreElements(); ) {
JarEntry entry = (JarEntry) entries.nextElement();
diff --git a/xbean-spring/src/main/java/org/apache/xbean/spring/generator/Type.java b/xbean-spring/src/main/java/org/apache/xbean/spring/generator/Type.java
index 5eac64c..0d9fa63 100644
--- a/xbean-spring/src/main/java/org/apache/xbean/spring/generator/Type.java
+++ b/xbean-spring/src/main/java/org/apache/xbean/spring/generator/Type.java
@@ -41,12 +41,7 @@ public class Type {
public static Type newArrayType(String type, int dimensions) {
if (type == null) throw new NullPointerException("type");
if (dimensions < 1) throw new IllegalArgumentException("dimensions must be atleast one");
- StringBuffer buf = new StringBuffer(type.length() + (dimensions * 2));
- buf.append(type);
- for (int i = 0; i < dimensions; i ++) {
- buf.append("[]");
- }
- return new Type(buf.toString(), newSimpleType(type));
+ return new Type(type, newSimpleType(type.replaceAll("\\[\\]", "")));
}
public static Type newCollectionType(String collectionType, Type elementType) {
--
2.9.3

View File

@ -0,0 +1,35 @@
From 28e37850d8343f44f82e3138c772dd65d1d0ff2f Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Thu, 12 Dec 2019 08:52:26 +0100
Subject: [PATCH 3/3] Remove dependency on log4j and commons-logging
---
.../xbean/propertyeditor/PropertyEditorRegistry.java | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/PropertyEditorRegistry.java b/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/PropertyEditorRegistry.java
index e7e17edd..be302861 100644
--- a/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/PropertyEditorRegistry.java
+++ b/xbean-reflect/src/main/java/org/apache/xbean/propertyeditor/PropertyEditorRegistry.java
@@ -84,18 +84,6 @@ public class PropertyEditorRegistry implements Closeable {
register(new VectorEditor());
register(new WeakHashMapEditor());
- try {
- register(new Log4jConverter());
- } catch (final Throwable e) {
- // no-op
- }
-
- try {
- register(new CommonsLoggingConverter());
- } catch (final Throwable e) {
- // no-op
- }
-
return this;
}
--
2.21.0

BIN
xbean-4.20-source-release.zip (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:501a3cdacd5c42d0e5f691a0c3fd903a5f335f0d446f96c0be52ab0c58533b17
size 1017685

3
xbean-build.tar.xz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0ab2b6f7661dc3d5763bb96acb2e67944ea11f28eea930c6e2713d9a99ef9d5c
size 2332

View File

@ -1,3 +1,51 @@
-------------------------------------------------------------------
Mon Mar 7 09:46:33 UTC 2022 - Fridrich Strba <fstrba@suse.com>
- Upgrade to version 4.20
* Bugs
+ XBEAN-298: FileArchive can lead to NPE
+ XBEAN-326: NullpointerException in BundleAssignableClassFinder
+ XBEAN-327: ASM9 bundle
+ XBEAN-328: Upgrade to asm 9.0
+ XBEAN-329: trunk does not build due to unused import
+ XBEAN-330: Wrong OSGi manifests in xbean-asm9-shaded
+ XBEAN-331: Upgrade to asm 9.1
* Improvements
+ XBEAN-301: Add Automatic-Module-Name to xbean manifest
+ XBEAN-303: asm shade NOTICE file shouldnt exist
+ XBEAN-306: MultiJar release support enhancements
+ XBEAN-309: Support Constructors and Static Factory Methods
in xbean-reflect
+ XBEAN-310: Provide a PropertyEditorRegistry
+ XBEAN-312: Ensure multi-jar are not scanned twice
+ XBEAN-318: xbean-finder should log the class name on errors
+ XBEAN-319: Enable xbean-finder to not store classes without
annotations
+ XBEAN-320: Enable xbean-finder to not track some annotations
+ XBEAN-322: Upgrade to ASM 7.2
* New Features
+ XBEAN-305: Asm 6.1.1 upgrade
+ XBEAN-313: Create asm7 bundle
* Tasks
+ XBEAN-296: upgrade to asm 6
+ XBEAN-302: Upgrade to asm 6.1
+ XBEAN-308: ASM 6.2 upgrade
+ XBEAN-311: ASM 6.2.1
+ XBEAN-314: ASM 7.0 upgrade
+ XBEAN-316: Upgrade ASM to 7.1
+ XBEAN-321: Upgrade to asm 7.2-beta
+ XBEAN-323: Upgrade ASM to 7.3.1
+ XBEAN-325: Upgrade to asm 8
- Removed patch:
* 0003-Port-to-QDox-2.0.patch
+ not needed in modules that we build
- Changed patch:
* 0001-Unshade-ASM.patch -> 0002-Unbundle-ASM.patch
+ Different ASM version and code structure
- Added patch:
* 0003-Remove-dependency-on-log4j-and-commons-logging.patch
+ Remove unnecessary dependency on log4j and commons-logging
-------------------------------------------------------------------
Tue Feb 22 18:53:19 UTC 2022 - Fridrich Strba <fstrba@suse.com>

View File

@ -17,28 +17,24 @@
Name: xbean
Version: 4.5
Version: 4.20
Release: 0
Summary: Java plugin based web server
License: Apache-2.0
Group: Development/Libraries/Java
URL: https://geronimo.apache.org/xbean/
Source0: http://repo2.maven.org/maven2/org/apache/%{name}/%{name}/%{version}/%{name}-%{version}-source-release.zip
# Fix dependency on xbean-asm4-shaded to original objectweb-asm
Patch0: 0001-Unshade-ASM.patch
Patch2: 0003-Port-to-QDox-2.0.patch
BuildRequires: apache-commons-logging
Source0: https://repo1.maven.org/maven2/org/apache/%{name}/%{name}/%{version}/%{name}-%{version}-source-release.zip
Source1: %{name}-build.tar.xz
Patch2: 0002-Unbundle-ASM.patch
Patch3: 0003-Remove-dependency-on-log4j-and-commons-logging.patch
BuildRequires: ant
BuildRequires: fdupes
BuildRequires: java-devel >= 1.8
BuildRequires: java-devel >= 1.7
BuildRequires: javapackages-local
BuildRequires: objectweb-asm >= 5
BuildRequires: reload4j
BuildRequires: objectweb-asm >= 9
BuildRequires: slf4j
BuildRequires: unzip
# The code uses sun.misc.URLClassloader
BuildConflicts: java-devel >= 9
BuildConflicts: java-headless >= 9
Requires: objectweb-asm >= 5
Requires: objectweb-asm >= 9
Requires: slf4j
BuildArch: noarch
@ -58,81 +54,71 @@ Group: Documentation/HTML
This package provides API documentation for xbean.
%prep
%setup -q
# build failing on this due to doxia-sitetools problems
rm src/site/site.xml
%patch0 -p1
%setup -q -a1
%patch2 -p1
%patch3 -p1
cp xbean-asm-util/src/main/java/org/apache/xbean/asm9/original/commons/AsmConstants.java xbean-reflect/src/main/java/org/apache/xbean/recipe/
# Parent POM is not packaged
%pom_remove_parent
%pom_remove_dep mx4j:mx4j
%pom_remove_dep -r :xbean-asm5-shaded
%pom_remove_dep -r :xbean-finder-shaded
%pom_disable_module xbean-asm5-shaded
%pom_disable_module xbean-finder-shaded
for i in xbean-asm-util xbean-finder xbean-reflect; do
%pom_remove_parent ${i}
%pom_xpath_inject pom:project "<groupId>org.apache.xbean</groupId><version>%{version}</version>" ${i}
done
%pom_xpath_remove pom:scope xbean-asm-util
%pom_xpath_remove pom:optional xbean-asm-util
# Prevent modules depending on springframework from building.
%pom_remove_dep org.springframework:
%pom_disable_module xbean-classloader
%pom_disable_module xbean-spring
%pom_disable_module maven-xbean-plugin
rm -rf maven-xbean-plugin
# blueprint FTBFS, disable for now
%pom_disable_module xbean-classpath
%pom_disable_module xbean-bundleutils
%pom_disable_module xbean-asm9-shaded
%pom_disable_module xbean-finder-shaded
%pom_disable_module xbean-naming
%pom_disable_module xbean-blueprint
%pom_disable_module xbean-spring
%pom_disable_module xbean-telnet
%pom_disable_module maven-xbean-plugin
%pom_remove_dep :commons-logging-api xbean-reflect
%pom_remove_dep :log4j xbean-reflect
%pom_remove_dep :xbean-asm9-shaded xbean-reflect
find -name CommonsLoggingConverter.java -delete
find -name Log4jConverter.java -delete
# Plugins useful for upstream only
%pom_remove_plugin :apache-rat-plugin
%pom_remove_plugin :maven-source-plugin
%pom_remove_dep :xbean-bundleutils xbean-finder
%pom_remove_dep org.osgi:org.osgi.core xbean-finder
rm -r xbean-finder/src/main/java/org/apache/xbean/finder{,/archive}/Bundle*
%pom_disable_module xbean-bundleutils
%pom_disable_module xbean-telnet
# maven-xbean-plugin invocation makes no sense as there are no namespaces
%pom_remove_plugin :maven-xbean-plugin xbean-classloader
# As auditing tool RAT is useful for upstream only.
%pom_remove_plugin :apache-rat-plugin
# disable copy of internal aries-blueprint
sed -i "s|<Private-Package>|<!--Private-Package>|" xbean-blueprint/pom.xml
sed -i "s|</Private-Package>|</Private-Package-->|" xbean-blueprint/pom.xml
%pom_change_dep -r -f ::::: :::::
%build
for i in xbean-asm-util xbean-classpath xbean-finder xbean-naming xbean-reflect; do
pushd $i
mkdir -p build/classes
javac -d build/classes -encoding utf-8 -source 6 -target 6 \
-cp $(build-classpath reload4j commons-logging-api slf4j/api objectweb-asm/asm objectweb-asm/asm-commons):../xbean-asm-util/xbean-asm-util.jar \
$(find src/main/java -name *.java)
jar cf $i.jar -C build/classes .
popd
done
mkdir -p build/apidoc
javadoc -d build/apidoc -source 6 -encoding utf-8 \
-classpath $(build-classpath reload4j commons-logging-api slf4j/api objectweb-asm/asm objectweb-asm/asm-commons) \
$(for i in xbean-asm-util xbean-classpath xbean-finder xbean-naming xbean-reflect; do find $i/src/main/java -name *.java; done | xargs)
mkdir -p lib
build-jar-repository -s lib objectweb-asm slf4j
%{ant} package javadoc
%install
# jars && poms
# jars
install -dm 755 %{buildroot}%{_javadir}/%{name}
for i in xbean-asm-util xbean-finder xbean-reflect; do
install -m 0644 ${i}/target/${i}-%{version}.jar %{buildroot}%{_javadir}/%{name}/${i}.jar
done
# poms
install -dm 755 %{buildroot}%{_mavenpomdir}/%{name}
for i in xbean-asm-util xbean-classpath xbean-finder xbean-naming xbean-reflect; do
install -m 0644 $i/$i.jar %{buildroot}%{_javadir}/%{name}
%pom_remove_parent ${i}
%pom_xpath_inject pom:project "<groupId>org.apache.xbean</groupId><version>%{version}</version>" ${i}
install -m 0644 $i/pom.xml %{buildroot}%{_mavenpomdir}/%{name}/$i.pom
%add_maven_depmap %{name}/$i.pom %{name}/$i.jar
for i in xbean-asm-util xbean-finder xbean-reflect; do
install -m 0644 ${i}/pom.xml %{buildroot}%{_mavenpomdir}/%{name}/${i}.pom
%add_maven_depmap %{name}/${i}.pom %{name}/${i}.jar
done
# javadoc
install -dm 755 %{buildroot}/%{_javadocdir}/%{name}
cp -aL build/apidoc/* %{buildroot}/%{_javadocdir}/%{name}
for i in xbean-asm-util xbean-finder xbean-reflect; do
cp -r ${i}/target/site/apidocs %{buildroot}/%{_javadocdir}/%{name}/${i}
done
%fdupes -s %{buildroot}/%{_javadocdir}/%{name}
%files -f .mfiles