Uploaded image for project: 'JBoss Marshalling'
  1. JBoss Marshalling
  2. JBMAR-124

Deserializing EnumSets with IBM JDK breaks using the River protocol

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.3.1.GA, 2.0.0.Beta1
    • 1.3.0.GA
    • River

      When an EnumSet is is serialized on a Sun JDK and then then deserialized on an IBM JDK you'll run into IllegalStateException: "No standard field found for reverse order comparator!" at org.jboss.marshalling.river.Protocol.<clinit>(Protocol.java:216)

      Background:

      There is a three node infinispan cluster all running Sun JVMs. A forth node is added running an IBM JVM.

      While executing the following method:

      public List<Consumo> getConsumos(ConsumoFilter filter)

      { Properties props = new Properties(); props.put("infinispan.client.hotrod.server_list", "10.250.2.38:11222"); CacheContainer cacheContainer = new RemoteCacheManager(props); Cache<String, String> cache = cacheContainer.getCache(); cache.put("car", "ferrari"); // In this line there is an exception in IBM JRE ...}

      Using JRE ibm-java-i386-60 the following exception appears:

      ...
      Caused by: java.lang.IllegalStateException: No standard field found for reverse order comparator!
      at org.jboss.marshalling.river.Protocol.<clinit>(Protocol.java:216)
      at java.lang.J9VMInternals.initializeImpl(Native Method)
      at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
      ... 57 more

      In org.jboss.marshalling.river.Protocol there is a statitic initializer:

      /* */ static final Class<?> reverseOrder2Class = Collections.reverseOrder(Collections.reverseOrder()).getClass();
      /* */ static
      /* */ {
      /* */ Class clazz;
      /* */ try
      /* */

      { /* 203 */ clazz = Class.forName("java.util.EnumSet$SerializationProxy"); /* */ }

      catch (ClassNotFoundException e)

      { /* 205 */ throw new IllegalStateException("No standard serialization proxy found for enum set!"); /* */ }

      /* 207 */ enumSetProxyClass = clazz;
      /* 208 */ Field field = null;
      /* 209 */ for (Field declared : reverseOrder2Class.getDeclaredFields()) {
      /* 210 */ if (declared.getName().equals("cmp"))

      { /* 211 */ declared.setAccessible(true); /* 212 */ field = declared; /* */ }

      /* */ }
      /* 215 */ if (field == null)

      { /* 216 */ throw new IllegalStateException("No standard field found for reverse order comparator!"); /* */ }

      /* 218 */ reverseOrder2Field = field;
      /* */ }

      The bug is produce cause the class reverseOrder2Class does not have the field "cmp"
      In JRE java-6-sun-1.6.0.26, the class reverseOrder2Class is:

      private static class ReverseComparator2<T> implements Comparator<T>, Serializable
      {
      private static final long serialVersionUID = 4374092139857L;

      /**

      • The comparator specified in the static factory. This will never
      • be null, as the static factory returns a ReverseComparator
      • instance if its argument is null.
        *
      • @serial
        */
        private Comparator<T> cmp;

      ReverseComparator2(Comparator<T> cmp)

      { assert cmp != null; this.cmp = cmp; }

      public int compare(T t1, T t2)

      { return cmp.compare(t2, t1); }

      }

      In JRE ibm-java2-60, the class reverseOrder2Class is:

      private static final class ReverseComparatorWithComparator<T> implements Comparator<T>, Serializable {
      private static final long serialVersionUID = 4374092139857L;

      private final Comparator<T> comparator;

      ReverseComparatorWithComparator(Comparator<T> comparator)

      { super(); this.comparator = comparator; }

      public int compare(T o1, T o2)

      { return comparator.compare(o2, o1); }

      }

      The complete exception stack is:

      ar.com.acme.framework.persistence.exception.PersistenceException: AOP Transform null
      at java.lang.J9VMInternals.initialize(J9VMInternals.java:220)
      at org.jboss.marshalling.river.RiverMarshaller.<clinit>(RiverMarshaller.java:1215)
      at java.lang.J9VMInternals.initializeImpl(Native Method)
      at java.lang.J9VMInternals.initialize(J9VMInternals.java:198)
      at org.jboss.marshalling.river.RiverMarshallerFactory.createMarshaller(RiverMarshallerFactory.java:58)
      at org.infinispan.marshall.jboss.GenericJBossMarshaller$1.initialValue(GenericJBossMarshaller.java:95)
      at org.infinispan.marshall.jboss.GenericJBossMarshaller$1.initialValue(GenericJBossMarshaller.java:91)
      at java.lang.ThreadLocal$ThreadLocalMap.getAfterMiss(ThreadLocal.java:433)

      Caused by: java.lang.ExceptionInInitializerError
      ... 60 more
      Caused by: java.lang.IllegalStateException: No standard field found for reverse order comparator!
      at org.jboss.marshalling.river.Protocol.<clinit>(Protocol.java:216)
      at java.lang.J9VMInternals.initializeImpl(Native Method)
      at java.lang.J9VMInternals.initialize(J9VMInternals.java:198)
      ... 59 more

              dlloyd@redhat.com David Lloyd
              rhn-sales-rploski Raymond Ploski (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: