This discussion is archived
1 2 Previous Next 26 Replies Latest reply: Oct 28, 2012 5:53 AM by ptoye Go to original post RSS
  • 15. Re: Illegal Argument exception within Swing
    abillconsl Explorer
    Currently Being Moderated
    ptoye wrote:
    Oracle change something, don't test it and get surprised and defensive when people complain. The way of the world.
    Yup, though in this case hopefully they'll at least fix it.
  • 16. Re: Illegal Argument exception within Swing
    doremifasollatido Journeyer
    Currently Being Moderated
    ptoye wrote:
    doremifasollatido wrote:
    javax.swing.LayoutComparator seems to be the default comparator for the javax.swing.LayoutFocusTraversalPolicy, and LayoutComparator doesn't define equals. This seems to be a bug in Java 7---they didn't define equals in LayoutComparator, so sorting now fails.

    Indeed, this bug has already been reported:
    http://webcache.googleusercontent.com/search?q=cache:QDf6QjnHLS8J:bugs.sun.com/bugdatabase/view_bug.do%3Fbug_id%3D7176968+&cd=12&hl=en&ct=clnk&gl=us
    Thanks. That bug (7176968) seems to have disappeared from the Oracle bug database. I begin to get the feeling that Oracle are removing adverse comments. I wonder why?

    [later] I tried setting the property. The article you reference doesn't tell me what to set it to. So I tried null (not allowed), "0" and "1" both of which don't change anything. All a bit dispiriting really.
    I'd guess that you should set the property to "true". Based on the name, I'd say it needs a boolean value. I know nothing about it--I use Java 6, and found the cited reference and bug from a Google search. Good luck!
  • 17. Re: Illegal Argument exception within Swing
    ptoye Newbie
    Currently Being Moderated
    doremifasollatido wrote:
    I'd guess that you should set the property to "true". Based on the name, I'd say it needs a boolean value. I know nothing about it--I use Java 6, and found the cited reference and bug from a Google search. Good luck!
    Tried "true". Still no change! Ditto with the empty string. Not impressed.

    Edited by: ptoye on Oct 25, 2012 2:53 AM Added quote.
  • 18. Re: Illegal Argument exception within Swing
    abillconsl Explorer
    Currently Being Moderated
    Why don't you just go back to v6x until this gets fixed? That's what I would do anyway. Less aggravation is better.
  • 19. Re: Illegal Argument exception within Swing
    DarrylBurke Guru Moderator
    Currently Being Moderated
    doremifasollatido wrote:
    I'd guess that you should set the property to "true". Based on the name, I'd say it needs a boolean value. I know nothing about it--I use Java 6, and found the cited reference and bug from a Google search. Good luck!
    From looking at the Java 7 source code of java.util.Arrays, I'd guess that you need to set <tt>"java.util.Arrays.useLegacyMergeSort"</tt> to <tt>Boolean.TRUE</tt>. There's a nested class
        static final class LegacyMergeSort {
            private static final boolean userRequested =
                java.security.AccessController.doPrivileged(
                    new sun.security.action.GetBooleanAction(
                        "java.util.Arrays.useLegacyMergeSort")).booleanValue();
        }
    and the sort(...) methods use this:
        public static void sort(Object[] a) {
            if (LegacyMergeSort.userRequested)
                legacyMergeSort(a);
            else
                ComparableTimSort.sort(a);
        }
    db
  • 20. Re: Illegal Argument exception within Swing
    doremifasollatido Journeyer
    Currently Being Moderated
    Darryl Burke wrote:
    doremifasollatido wrote:
    I'd guess that you should set the property to "true". Based on the name, I'd say it needs a boolean value. I know nothing about it--I use Java 6, and found the cited reference and bug from a Google search. Good luck!
    From looking at the Java 7 source code of java.util.Arrays, I'd guess that you need to set <tt>"java.util.Arrays.useLegacyMergeSort"</tt> to <tt>Boolean.TRUE</tt>.
    But, you have to set properties to String values, so to get <tt>Boolean.TRUE</tt>, you would need to use the String <tt>"true"</tt>, as I suggested:
     System.setProperty("java.util.Arrays.useLegacyMergeSort", "true"); 
    Or, from the command line:
    <tt> -Djava.util.Arrays.useLegacyMergeSort=true </tt>
  • 21. Re: Illegal Argument exception within Swing
    ptoye Newbie
    Currently Being Moderated
    abillconsl wrote:
    Why don't you just go back to v6x until this gets fixed?
    I'm thinking of it, but one of my other projects needs v7.

    And I get the feeling that trying to keep the versions separate would involve just as much aggravation. Especially installing v 6 after v 7.
  • 22. Re: Illegal Argument exception within Swing
    ptoye Newbie
    Currently Being Moderated
    doremifasollatido wrote:

    But, you have to set properties to String values, so to get <tt>Boolean.TRUE</tt>, you would need to use the String <tt>"true"</tt>, as I suggested:
     System.setProperty("java.util.Arrays.useLegacyMergeSort", "true"); 
    Or, from the command line:
    <tt> -Djava.util.Arrays.useLegacyMergeSort=true </tt>
    As I said elsewhere the System.setProperty doesn't work. Neither does the suggestion of using "Boolean.TRUE" (and various combinations of upper- and lower-case). I've not looked for the

    But your command line works! Thanks very much.

    [later] After setting the property from the command line option, I printed out the value using System.getProperty - it's "true". But setting it to "true" using System.setProperty doesn't work.

    Is there some Boolean property type that can't be set from program, but can by command line?

    Edited by: ptoye on Oct 26, 2012 11:15 AM
  • 23. Re: Illegal Argument exception within Swing
    ptoye Newbie
    Currently Being Moderated
    Darryl Burke wrote:
    From looking at the Java 7 source code of java.util.Arrays, I'd guess that you need to set <tt>"java.util.Arrays.useLegacyMergeSort"</tt> to <tt>Boolean.TRUE</tt>. There's a nested class
        static final class LegacyMergeSort {
    private static final boolean userRequested =
    java.security.AccessController.doPrivileged(
    new sun.security.action.GetBooleanAction(
    "java.util.Arrays.useLegacyMergeSort")).booleanValue();
    }
    and the sort(...) methods use this:
        public static void sort(Object[] a) {
    if (LegacyMergeSort.userRequested)
    legacyMergeSort(a);
    else
    ComparableTimSort.sort(a);
    }
    db
    Yes, but what's the syntax of the property string? I've tried "true", "TRUE", "Boolean.true", "Boolean.TRUE", "boolean.TRUE" and other combinations of upper- and lower-case. And the sun.security.action package isn't in the published Javadoc so it's not easy to find out just what it wants.
  • 24. Re: Illegal Argument exception within Swing
    DarrylBurke Guru Moderator
    Currently Being Moderated
    doremifasollatido wrote:
    But, you have to set properties to String values, so to get <tt>Boolean.TRUE</tt>, you would need to use the String <tt>"true"</tt>, as I suggested:
    Ah, right. Sorry about that.

    db
  • 25. Re: Illegal Argument exception within Swing
    DarrylBurke Guru Moderator
    Currently Being Moderated
    ptoye wrote:
    Yes, but what's the syntax of the property string? I've tried "true", "TRUE", "Boolean.true", "Boolean.TRUE", "boolean.TRUE" and other combinations of upper- and lower-case. And the sun.security.action package isn't in the published Javadoc so it's not easy to find out just what it wants.
    The correct value woud be <tt><b>"true"</b></tt>, as recommended by doremifasollatido. But since the property is accessed from a static context, it would need to be set <b>before</b> the Arrays class is loaded.

    I guess you could try setting it from within a static initializer in your class that has the main(...) method and see if that takes. If it doesn't, you're left with the command line argument as the only option.

    db
  • 26. Re: Illegal Argument exception within Swing
    ptoye Newbie
    Currently Being Moderated
    Darryl Burke wrote:
    I guess you could try setting it from within a static initializer in your class that has the main(...) method and see if that takes. If it doesn't, you're left with the command line argument as the only option.

    db
    Brilliant - thanks. I should have noticed the static context from your previous post.

    Of course, this hasn't answered my original question, which I'm now sure is a bug in Swing, where Oracle didn't notice that one of their comparators doesn't work properly. I've reported it, but it's not appeared on the bug database, so either they're very busy taking out all the bugs they put into v7, or they've gone into sulk mode.

    Edited by: ptoye on Oct 28, 2012 5:53 AM
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points