java.util.Queue backport

2006-09-24
2013-04-23
  • John V Sichi

    John V Sichi - 2006-09-24

    When I test a retrowoven class with code like this:

    ArrayBlockingQueue<String> q = new ArrayBlockingQueue<String>(100);
    q.add("hi");

    all is well.  But if I change it to:

    Queue<String> q = new ArrayBlockingQueue<String>(100);
    q.add("hi");

    I get the error stack below.  I read in another forum post that references to java.util.concurrent are woven, but I guess that leaves out java.util?  Is that unavoidable because java.util is special, or just an oversight?

        [junit] Testsuite: org.jgrapht.traverse.TopologicalOrderIteratorTest
        [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0.038 sec

        [junit] Testcase: testRecipe(org.jgrapht.traverse.TopologicalOrderIteratorTest):    Caused an ERROR
        [junit] Prohibited package name: java.util
        [junit] java.lang.SecurityException: Prohibited package name: java.util
        [junit]     at java.lang.ClassLoader.defineClass(ClassLoader.java:524)
        [junit]     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
        [junit]     at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
        [junit]     at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
        [junit]     at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
        [junit]     at java.security.AccessController.doPrivileged(Native Method)
        [junit]     at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
        [junit]     at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
        [junit]     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)    [junit]     at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
        [junit]     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)    [junit]     at org.jgrapht.traverse.TopologicalOrderIteratorTest.testRecipe(TopologicalOrderIteratorTest.java:105)

    JVS

     
    • Toby Reyelts

      Toby Reyelts - 2006-09-25

      Hi John,

      It looks to me like we just need to add a rule for java.util.Queue to weave it to the backport Queue. If you're using the new 2.0 beta, you should be able to add the rule in NameTranslator.java:

      generalTranslator.addNameSpace( new NameSpace("java.util.Queue", "edu.emory.mathcs.backport.java.util.concurrent.Queue" ) );

      Warning: I haven't tested that myself yet, but it should work.

      We'll make this work out of the box in the next release.

       
      • John V Sichi

        John V Sichi - 2006-09-26

        Thanks!

        Looking into the backport jar, there are a bunch of other classes outside of concurrent.  I'm not sure if the overlapping ones like Collections can be handled.

          -rw-r--r--       816   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/AbstractCollection.class
          -rw-r--r--       792   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/AbstractList.class
          -rw-r--r--      1286   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/AbstractMap$1.class
          -rw-r--r--      1355   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/AbstractMap$2.class
          -rw-r--r--      1831   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/AbstractMap$SimpleEntry.class
          -rw-r--r--      1879   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/AbstractMap$SimpleImmutableEntry.class
          -rw-r--r--      1188   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/AbstractMap.class
          -rw-r--r--      1605   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/AbstractQueue.class
          -rw-r--r--       832   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/AbstractSequentialList.class
          -rw-r--r--       788   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/AbstractSet.class
          -rw-r--r--       243   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/ArrayDeque$1.class
          -rw-r--r--      1991   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/ArrayDeque$DeqIterator.class
          -rw-r--r--      2012   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/ArrayDeque$DescendingIterator.class
          -rw-r--r--      9606   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/ArrayDeque.class
          -rw-r--r--     16906   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/Arrays.class
          -rw-r--r--      1651   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/Collections$1.class
          -rw-r--r--      2712   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/Collections$AsLifoQueue.class
          -rw-r--r--      1157   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/Collections$CheckedCollection$Itr.class
          -rw-r--r--      3643   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/Collections$CheckedCollection.class
          -rw-r--r--      1803   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/Collections$CheckedList$ListItr.class
          -rw-r--r--      3416   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/Collections$CheckedList.class
          -rw-r--r--      3471   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/Collections$CheckedMap$EntrySetView.class
          -rw-r--r--      1760   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/Collections$CheckedMap$EntryView.class
          -rw-r--r--      4588   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/Collections$CheckedMap.class
          -rw-r--r--      1040   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/Collections$CheckedSet.class
          -rw-r--r--      1664   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/Collections$CheckedSortedMap.class
          -rw-r--r--      1584   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/Collections$CheckedSortedSet.class
          -rw-r--r--       807   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/Collections$ReverseComparator.class
          -rw-r--r--      3096   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/Collections$SetFromMap.class
          -rw-r--r--     10059   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/Collections.class
          -rw-r--r--       791   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/Deque.class
          -rw-r--r--      3016   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/LinkedList$DescItr.class
          -rw-r--r--       552   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/LinkedList$Entry.class
          -rw-r--r--      3007   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/LinkedList$Itr.class
          -rw-r--r--     10808   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/LinkedList.class
          -rw-r--r--      1155   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/NavigableMap.class
          -rw-r--r--       840   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/NavigableSet.class
          -rw-r--r--      2249   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/PriorityQueue$Itr.class
          -rw-r--r--      8199   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/PriorityQueue.class
          -rw-r--r--       297   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/Queue.class
          -rw-r--r--      3721   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$AscendingKeySet.class
          -rw-r--r--      3365   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$AscendingSubMap.class
          -rw-r--r--      2006   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$BaseEntryIterator.class
          -rw-r--r--      1090   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$DescendingEntryIterator.class
          -rw-r--r--      1192   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$DescendingEntrySet.class
          -rw-r--r--      1184   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$DescendingKeyIterator.class
          -rw-r--r--      3768   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$DescendingKeySet.class
          -rw-r--r--      3300   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$DescendingSubMap.class
          -rw-r--r--      1190   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$DescendingValueIterator.class
          -rw-r--r--      3683   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$Entry.class
          -rw-r--r--      1060   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$EntryIterator.class
          -rw-r--r--      1846   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$EntrySet.class
          -rw-r--r--      1766   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$IOIterator.class
          -rw-r--r--       738   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$IteratorIOException.class
          -rw-r--r--       805   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$IteratorNoClassException.class
          -rw-r--r--      1154   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$KeyIterator.class
          -rw-r--r--      2156   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$KeySet.class
          -rw-r--r--      2204   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$NavigableSubMap$SubEntryIterator.class
          -rw-r--r--      1972   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$NavigableSubMap$SubEntrySet.class
          -rw-r--r--      1237   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$NavigableSubMap$SubKeyIterator.class
          -rw-r--r--      5045   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$NavigableSubMap$SubKeySet.class
          -rw-r--r--     10069   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$NavigableSubMap.class
          -rw-r--r--      3941   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$SubMap.class
          -rw-r--r--      1160   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$ValueIterator.class
          -rw-r--r--      2061   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap$ValueSet.class
          -rw-r--r--     20015   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeMap.class
          -rw-r--r--      1747   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeSet$IOIterator.class
          -rw-r--r--      1114   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeSet$MapIterator.class
          -rw-r--r--      7982   4-Jun-2006  14:10:12  edu/emory/mathcs/backport/java/util/TreeSet.class
          -rw-r--r--      7884   4-Jun-2006  14:10:12 

        JVS

         
        • Toby Reyelts

          Toby Reyelts - 2006-09-26

          In general, we don't replace classes which are a part of the JDK prior to JDK 1.5, because it introduces compatibility issues. (Are you really sure you want all your uses of TreeSet to be replaced by edu.emory.mathcs.backport.java.util.TreeSet?)

          With configurable mirrors, you can pick and choose which classes you'd like to have replaced. We'll make new API additions part of the default setup.

           
          • John V Sichi

            John V Sichi - 2006-09-26

            Makes sense.  LinkedList is kind of interesting because it got retrofitted to implement the Queue interface; maybe I'll just use an adapter in that case to avoid having to deal with the compatibility issues.

            JVS

             
            • Xavier Le Vourch

              Support for the following (new in 1.5 or 1.6) classes was added:
                AbstractQueue, ArrayDeque, Deque, NavigableMap,
                NavigableSet, PriorityQueue, Queue

              For the LinkedList class, we could add the missing Queue methods as static methods in a LinkedList_ class in retroweaver so that the newer methods would be supported but you still would not be able to manipulate a LinkedList as a Queue.

              Xavier

               
    • John V Sichi

      John V Sichi - 2006-12-23

      Hi guys,

      I'm testing 2.0Beta2, but the problem only seems to be partially fixed.  Add the test method below to test/java/net/sourceforge/retroweaver/tests/ConcurrentTest.java.  Then try to run the test.  I get the stack at the bottom.  Looking at the retrowoven ConcurrentTest.class, it appears that some of the references to Queue got replaced with the backport, but some are still referencing jav.util.Queue (hence the error).

          public void testQueueAsField() {
              Queue<String> q3 = new PriorityQueue<String>(100);
              QueuePee<String> qp = new QueuePee<String>(q3);
              assertEquals("testQueue", "hi", q3.peek());
          }

          private static class QueuePee<T> {
              Queue<T> q;

              QueuePee(Queue<T> q)
              {
                  this.q = q;
              }
          }

      test14:
          [junit] Testsuite: net.sourceforge.retroweaver.tests.RetroweaverTestSuite
          [junit] Tests run: 82, Failures: 0, Errors: 1, Time elapsed: 0.252 sec

          [junit] Testcase: testQueueAsField(net.sourceforge.retroweaver.tests.ConcurrentTest):       Caused an ERROR
          [junit] Prohibited package name: java.util
          [junit] java.lang.SecurityException: Prohibited package name: java.util
          [junit]     at java.lang.ClassLoader.defineClass(ClassLoader.java:524)
          [junit]     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
          [junit]     at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
          [junit]     at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
          [junit]     at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
          [junit]     at java.security.AccessController.doPrivileged(Native Method)
          [junit]     at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
          [junit]     at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
          [junit]     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
          [junit]     at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
          [junit]     at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
          [junit]     at net.sourceforge.retroweaver.tests.ConcurrentTest.testQueueAsField(ConcurrentTest.java:49)

      JVS

       
      • Xavier Le Vourch

        Hi John,

        Sorry about the late answer...

        I cannot reproduce this on my system with the latest svn version, I only get the normal failure as the list is empty so it does not contain "hi". java.util.Queue now only appears in the signature so it should be ignored by the 1.4 jvms.

        I've modified your test case using

          Queue<String> q3 = new PriorityQueue<String>(100);
          q3.add("hi");
          QueuePee<String> qp = new QueuePee<String>(q3);
          assertEquals("testQueue", "hi", qp.q.peek());

        and that works fine. I've added it in the test suite.

        Could you test with the latest code and see if the problem is fixed as I've changed field processing since Beta 2. If not, could you provide more info on the architecture and exact jvm version used?

        Thanks,

        Xavier

         
    • John V Sichi

      John V Sichi - 2007-01-29

      Thanks, I have verified that this is fixed in the 2.0Beta3 release.

      JVS

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks