This is an automated email from the ASF dual-hosted git repository.
thiagohp pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git
The following commit(s) were added to refs/heads/master by this push:
new aa12d279a TAP5-2813: Hopefully last workaround
aa12d279a is described below
commit aa12d279adbc06471257a96036435bd7095268ea
Author: Thiago H. de Paula Figueiredo <[email protected]>
AuthorDate: Sat Nov 8 11:00:24 2025 -0300
TAP5-2813: Hopefully last workaround
---
.../internal/services/PropertyAccessImpl.java | 36 +---------
.../plastic/AbstractAnnotationBuilder.java | 2 +-
.../tapestry5/corelib/pages/ExceptionReport.java | 15 ++---
.../tapestry5/internal/transform/CachedWorker.java | 78 ++++++++++++++++++----
.../app1/base/AbstractCachedGenerics.java | 2 +-
.../app1/components/CachedGenerics.java | 4 ++
.../integration/app1/components/CachedGenerics.tml | 5 ++
7 files changed, 84 insertions(+), 58 deletions(-)
diff --git
a/beanmodel/src/main/java/org/apache/tapestry5/beanmodel/internal/services/PropertyAccessImpl.java
b/beanmodel/src/main/java/org/apache/tapestry5/beanmodel/internal/services/PropertyAccessImpl.java
index 74ea07d59..ea214bcc8 100644
---
a/beanmodel/src/main/java/org/apache/tapestry5/beanmodel/internal/services/PropertyAccessImpl.java
+++
b/beanmodel/src/main/java/org/apache/tapestry5/beanmodel/internal/services/PropertyAccessImpl.java
@@ -96,7 +96,7 @@ public class PropertyAccessImpl implements PropertyAccess
try
{
- BeanInfo info = getBeanInfo(forClass);
+ BeanInfo info = Introspector.getBeanInfo(forClass);
List<PropertyDescriptor> descriptors = CollectionFactory.newList();
@@ -116,36 +116,6 @@ public class PropertyAccessImpl implements PropertyAccess
throw new RuntimeException(ex);
}
}
-
- private BeanInfo getBeanInfo(Class<?> forClass) throws
IntrospectionException
- {
- BeanInfo beanInfo;
- try
- {
- beanInfo = Introspector.getBeanInfo(forClass);
- } catch (IntrospectionException | NullPointerException e)
- {
-
- // TAP5-2813: if we get a problem while trying to inspect
- // the transformed class, let's try inspecting the original
- // class. This problem only happens in multiple classloader mode
- // AND using the @Cached annotation in a method that returns
- // a type with generics. Quite specific.
- Class<?> untransformedClass;
- try
- {
- untransformedClass = this.getClass().getClassLoader()
- .loadClass(forClass.getName());
- beanInfo = Introspector.getBeanInfo(untransformedClass);
- }
- catch (ClassNotFoundException e2)
- {
- throw new RuntimeException(e2);
- }
-
- }
- return beanInfo;
- }
private static <T> void addAll(List<T> list, T[] array)
{
@@ -164,7 +134,7 @@ public class PropertyAccessImpl implements PropertyAccess
}
}
- private void addPropertiesFromExtendedInterfaces(Class forClass,
List<PropertyDescriptor> descriptors)
+ private static void addPropertiesFromExtendedInterfaces(Class forClass,
List<PropertyDescriptor> descriptors)
throws IntrospectionException
{
@@ -180,7 +150,7 @@ public class PropertyAccessImpl implements PropertyAccess
{
Class c = queue.removeFirst();
- BeanInfo info = getBeanInfo(c);
+ BeanInfo info = Introspector.getBeanInfo(c);
// Duplicates occur and are filtered out in ClassPropertyAdapter
which stores
// a property name to descriptor map.
diff --git
a/plastic/src/main/java/org/apache/tapestry5/internal/plastic/AbstractAnnotationBuilder.java
b/plastic/src/main/java/org/apache/tapestry5/internal/plastic/AbstractAnnotationBuilder.java
index 4c97c872c..baf4956f5 100644
---
a/plastic/src/main/java/org/apache/tapestry5/internal/plastic/AbstractAnnotationBuilder.java
+++
b/plastic/src/main/java/org/apache/tapestry5/internal/plastic/AbstractAnnotationBuilder.java
@@ -30,7 +30,7 @@ public abstract class AbstractAnnotationBuilder extends
AnnotationVisitor
public AbstractAnnotationBuilder(PlasticClassPool pool)
{
- super(Opcodes.ASM4);
+ super(Opcodes.ASM9);
this.pool = pool;
}
diff --git
a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/ExceptionReport.java
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/ExceptionReport.java
index 985b38fa6..2d95dbb85 100644
---
a/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/ExceptionReport.java
+++
b/tapestry-core/src/main/java/org/apache/tapestry5/corelib/pages/ExceptionReport.java
@@ -12,6 +12,12 @@
package org.apache.tapestry5.corelib.pages;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.List;
+import java.util.regex.Pattern;
+
import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.EventContext;
import org.apache.tapestry5.alerts.AlertManager;
@@ -19,7 +25,6 @@ import org.apache.tapestry5.annotations.ContentType;
import org.apache.tapestry5.annotations.Import;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.UnknownActivationContextCheck;
-import org.apache.tapestry5.beanmodel.services.*;
import org.apache.tapestry5.commons.services.InvalidationEventHub;
import org.apache.tapestry5.commons.util.CollectionFactory;
import org.apache.tapestry5.corelib.base.AbstractInternalPage;
@@ -43,13 +48,6 @@ import org.apache.tapestry5.services.PageRenderLinkSource;
import org.apache.tapestry5.services.URLEncoder;
import org.apache.tapestry5.services.pageload.PageClassLoaderContextManager;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.regex.Pattern;
-
/**
* Responsible for reporting runtime exceptions. This page is quite verbose
and is usually overridden in a production
* application. When {@link
org.apache.tapestry5.http.TapestryHttpSymbolConstants#PRODUCTION_MODE} is
"true", it is very abbreviated.
@@ -192,7 +190,6 @@ public class ExceptionReport extends AbstractInternalPage
implements ExceptionRe
public void reportException(Throwable exception)
{
-
System.out.print(pageClassLoaderContextManager.getRoot().toRecursiveString());
rootException = exception;
rootURL = baseURLSource.getBaseURL(request.isSecure());
diff --git
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/CachedWorker.java
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/CachedWorker.java
index 142804497..32bf7e64b 100644
---
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/CachedWorker.java
+++
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/transform/CachedWorker.java
@@ -14,6 +14,16 @@
package org.apache.tapestry5.internal.transform;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
import org.apache.tapestry5.Binding;
import org.apache.tapestry5.BindingConstants;
import org.apache.tapestry5.ComponentResources;
@@ -28,25 +38,27 @@ import org.apache.tapestry5.json.JSONArray;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.model.ComponentModel;
import org.apache.tapestry5.model.MutableComponentModel;
-import org.apache.tapestry5.plastic.*;
+import org.apache.tapestry5.plastic.ClassInstantiator;
+import org.apache.tapestry5.plastic.ComputedValue;
+import org.apache.tapestry5.plastic.FieldHandle;
+import org.apache.tapestry5.plastic.InstanceContext;
+import org.apache.tapestry5.plastic.MethodAdvice;
+import org.apache.tapestry5.plastic.MethodDescription;
+import org.apache.tapestry5.plastic.MethodInvocation;
+import org.apache.tapestry5.plastic.PlasticClass;
+import org.apache.tapestry5.plastic.PlasticField;
+import org.apache.tapestry5.plastic.PlasticManagerDelegate;
+import org.apache.tapestry5.plastic.PlasticMethod;
+import org.apache.tapestry5.plastic.PlasticUtils;
import org.apache.tapestry5.plastic.PlasticUtils.FieldInfo;
+import org.apache.tapestry5.plastic.PropertyAccessType;
+import org.apache.tapestry5.plastic.PropertyValueProvider;
import org.apache.tapestry5.runtime.PageLifecycleListener;
import org.apache.tapestry5.services.BindingSource;
import org.apache.tapestry5.services.TransformConstants;
import org.apache.tapestry5.services.transform.ComponentClassTransformWorker2;
import org.apache.tapestry5.services.transform.TransformationSupport;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
-
/**
* Caches method return values for methods annotated with {@link Cached}.
*/
@@ -86,7 +98,6 @@ public class CachedWorker implements
ComponentClassTransformWorker2
MethodResultCache create(Object instance);
}
-
private class SimpleMethodResultCache implements MethodResultCache
{
private boolean cached;
@@ -275,16 +286,55 @@ public class CachedWorker implements
ComponentClassTransformWorker2
{
final MethodDescription description = method.getDescription();
+ // TAP5-2813
+ String genericSignature = description.genericSignature;
+ if (genericSignature != null)
+ {
+ genericSignature = getGenericSignature(method);
+ }
+
return new JSONObject(
MODIFIERS, description.modifiers,
RETURN_TYPE, description.returnType,
NAME, description.methodName,
- GENERIC_SIGNATURE, description.genericSignature,
+ GENERIC_SIGNATURE, genericSignature,
ARGUMENT_TYPES, new JSONArray(description.argumentTypes),
CHECKED_EXCEPTION_TYPES, new
JSONArray(description.checkedExceptionTypes),
WATCH, method.getAnnotation(Cached.class).watch());
}
+ private static String getGenericSignature(String signature)
+ {
+ int startIndex = signature.indexOf('<');
+ int endIndex = signature.lastIndexOf('>');
+ if (startIndex > 0 && endIndex > 0 && startIndex < endIndex)
+ {
+ String typesSignature = signature.substring(startIndex + 1,
endIndex);
+ final String[] types = typesSignature.split(";");
+ boolean changed = false;
+ for (int i = 0; i < types.length; i++)
+ {
+ if (types[i].startsWith("T"))
+ {
+ types[i] = "Ljava/lang/Object";
+ changed = true;
+ }
+ }
+ if (changed)
+ {
+ final String newGenericTypeSignature = "<" + String.join(";",
types) + ";>";
+ final String oldGenericTypeSignature =
signature.substring(startIndex, endIndex + 1);
+ signature = signature.replace(oldGenericTypeSignature,
newGenericTypeSignature);
+ }
+ }
+ return signature;
+ }
+
+ private static String getGenericSignature(PlasticMethod method)
+ {
+ return getGenericSignature(method.getDescription().genericSignature);
+ }
+
private void adviseMethod(PlasticClass plasticClass, PlasticMethod method,
Set<FieldInfo> fieldInfos,
MutableComponentModel model, Map<String, String>
extraMethodCachedWatchMap)
{
diff --git
a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/base/AbstractCachedGenerics.java
b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/base/AbstractCachedGenerics.java
index ad93c9e4f..a823b9e7a 100644
---
a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/base/AbstractCachedGenerics.java
+++
b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/base/AbstractCachedGenerics.java
@@ -12,7 +12,7 @@ public abstract class AbstractCachedGenerics<T, H>
protected abstract GenericsClass<T, H> createTable(List<T>
itemsInCurrentPage);
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "unchecked", "rawtypes" })
@Cached
public GenericsClass<T, H> getEmptyTable()
{
diff --git
a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/CachedGenerics.java
b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/CachedGenerics.java
index 8d4541466..e0d0f4602 100644
---
a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/CachedGenerics.java
+++
b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/components/CachedGenerics.java
@@ -2,6 +2,7 @@ package org.apache.tapestry5.integration.app1.components;
import java.util.List;
+import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.integration.app1.GenericsClass;
import org.apache.tapestry5.integration.app1.GenericsEntity;
import org.apache.tapestry5.integration.app1.base.AbstractCachedGenerics;
@@ -9,6 +10,9 @@ import
org.apache.tapestry5.integration.app1.base.AbstractCachedGenerics;
public class CachedGenerics extends AbstractCachedGenerics<GenericsEntity,
String>
{
+ @Property
+ private String string;
+
@Override
protected GenericsClass<GenericsEntity, String>
createTable(List<GenericsEntity> itemsInCurrentPage)
{
diff --git
a/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/components/CachedGenerics.tml
b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/components/CachedGenerics.tml
new file mode 100644
index 000000000..6cc099b2a
--- /dev/null
+++
b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/components/CachedGenerics.tml
@@ -0,0 +1,5 @@
+<t:extend xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
xmlns:p="tapestry:parameter">
+ <t:replace id="bottom">
+ <p>Some string property: ${string}</p>
+ </t:replace>
+</t:extend>