--- ./main/java/org/drools/util/ShadowProxyUtils.java 2007-08-18 17:32:04.000000000 +0300 +++ ./fixed/java/org/drools/util/ShadowProxyUtils.java 2007-08-24 11:18:14.000000000 +0300 @@ -36,6 +36,19 @@ private static final Class UNMODIFIABLE_MAP = Collections.unmodifiableMap( Collections.EMPTY_MAP ).getClass(); private static final Class UNMODIFIABLE_COLLECTION = Collections.unmodifiableCollection( Collections.EMPTY_LIST ).getClass(); + private static final Class PERSISTENT_COLLECTION; + + static { + Class clazz = null; + try { + clazz = Class.forName("org.hibernate.collection.PersistentCollection"); + } catch(ClassNotFoundException e) { + // well, not everybody uses hibernate ... + } finally { + PERSISTENT_COLLECTION = clazz; + } + } + private ShadowProxyUtils() { } @@ -57,7 +70,8 @@ try { if ( original instanceof Map && original != Collections.EMPTY_MAP && - !UNMODIFIABLE_MAP.isAssignableFrom( original.getClass() ) ) { + !UNMODIFIABLE_MAP.isAssignableFrom( original.getClass() ) && + (PERSISTENT_COLLECTION == null || !PERSISTENT_COLLECTION.isAssignableFrom( original.getClass()))) { /* empty and unmodifiable maps can't (and don't need to) be shadowed */ clone = original.getClass().newInstance(); @@ -66,7 +80,8 @@ } else if ( original instanceof Collection && original != Collections.EMPTY_LIST && original != Collections.EMPTY_SET && - !UNMODIFIABLE_COLLECTION.isAssignableFrom( original.getClass() ) ) { + !UNMODIFIABLE_COLLECTION.isAssignableFrom( original.getClass() ) && + (PERSISTENT_COLLECTION == null || !PERSISTENT_COLLECTION.isAssignableFrom( original.getClass()))) { /* empty and unmodifiable collections can't (and don't need to) be shadowed */ clone = original.getClass().newInstance();