ASF Bugzilla – Attachment 30970 Details for
Bug 55691
javax.el.ArrayELResolver.setValue not supporting arrays of primitives
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch
55691.diff (text/plain), 2.63 KB, created by
Christopher Schultz
on 2013-10-25 14:17:16 UTC
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Christopher Schultz
Created:
2013-10-25 14:17:16 UTC
Size:
2.63 KB
patch
obsolete
>Index: java/javax/el/ArrayELResolver.java >=================================================================== >--- java/javax/el/ArrayELResolver.java (revision 1535733) >+++ java/javax/el/ArrayELResolver.java (working copy) >@@ -88,10 +88,10 @@ > > int idx = coerce(property); > checkBounds(base, idx); >- if (value != null && >- !base.getClass().getComponentType().isAssignableFrom( >- value.getClass())) { >- throw new ClassCastException(Util.message(context, >+ if (value != null) { >+ if(!typesAreAssignable(base.getClass().getComponentType(), >+ value.getClass())) >+ throw new ClassCastException(Util.message(context, > "objectNotAssignable", value.getClass().getName(), > base.getClass().getComponentType().getName())); > } >@@ -99,6 +99,53 @@ > } > } > >+ /** >+ * A method that replaces Class.isAssignableFrom with one that can >+ * successfully compare primitive types with their wrapper types. >+ * >+ * @param a A Class >+ * @param b A Class >+ * >+ * @return <code>true</code> if type <code>b</code> can be >+ * assigned a value of type <code>a</code> (with possible >+ * auto-boxing). >+ */ >+ private boolean typesAreAssignable(Class<?> a, Class<?> b) { >+ if(a.isPrimitive()) >+ a = getPrimitiveWrapperType(a); >+ if(b.isPrimitive()) >+ b = getPrimitiveWrapperType(b); >+ >+ return a.isAssignableFrom(b); >+ } >+ >+ /** >+ * Converts a primitive type to its wrapper type. >+ * @param c A primitive Class (e.g. {@see java.lang.Integer#TYPE}) >+ * @return The primitive wrapper class for <code>c</code> >+ * (e.g. {@see java.lang.Integer.class}. >+ */ >+ private Class<?> getPrimitiveWrapperType(Class<?> c) { >+ if(Integer.TYPE == c) >+ return Integer.class; >+ if(Long.TYPE == c) >+ return Long.class; >+ if(Double.TYPE == c) >+ return Double.class; >+ if(Float.TYPE == c) >+ return Float.class; >+ if(Byte.TYPE == c) >+ return Byte.class; >+ if(Short.TYPE == c) >+ return Short.class; >+ if(Character.TYPE == c) >+ return Character.class; >+ if(Boolean.TYPE == c) >+ return Boolean.class; >+ >+ throw new IllegalArgumentException(c + " is not a primitive type"); >+ } >+ > @Override > public boolean isReadOnly(ELContext context, Object base, Object property) { > if (context == null) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 55691
: 30970