From e409a23fb5dffd67c843e99ef97467ff4a42c211 Mon Sep 17 00:00:00 2001 From: chiba Date: Thu, 8 Jul 2010 09:46:32 +0000 Subject: [PATCH] fixed JASSIST-118 git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@551 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- src/main/javassist/CtArray.java | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/javassist/CtArray.java b/src/main/javassist/CtArray.java index 92ca85e9..42fe6093 100644 --- a/src/main/javassist/CtArray.java +++ b/src/main/javassist/CtArray.java @@ -48,9 +48,14 @@ final class CtArray extends CtClass { } public CtClass[] getInterfaces() throws NotFoundException { - if (interfaces == null) - interfaces = new CtClass[] { - pool.get("java.lang.Cloneable"), pool.get("java.io.Serializable") }; + if (interfaces == null) { + Class[] intfs = Object[].class.getInterfaces(); + // java.lang.Cloneable and java.io.Serializable. + // If the JVM is CLDC, intfs is empty. + interfaces = new CtClass[intfs.length]; + for (int i = 0; i < intfs.length; i++) + interfaces[i] = pool.get(intfs[i].getName()); + } return interfaces; } @@ -60,11 +65,14 @@ final class CtArray extends CtClass { return true; String cname = clazz.getName(); - if (cname.equals(javaLangObject) - || cname.equals("java.lang.Cloneable") - || cname.equals("java.io.Serializable")) + if (cname.equals(javaLangObject)) return true; + CtClass[] intfs = getInterfaces(); + for (int i = 0; i < intfs.length; i++) + if (intfs[i].subtypeOf(clazz)) + return true; + return clazz.isArray() && getComponentType().subtypeOf(clazz.getComponentType()); } -- 2.39.5