Problem! [Java 7 Bug?]

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: dorpond, trevor, Azhrei

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Post Reply
Avotas
Cave Troll
Posts: 76
Joined: Mon Nov 22, 2010 8:42 am

Problem! [Java 7 Bug?]

Post by Avotas »

Hey,

One of my players is getting this error filling up their chat window. It seemly has no trigger and happens randomly throughout the game. Any ideas? (MapTool Build 87). The player is using Java 7 64 Bit


java.lang.IllegalArgumentException: Comparison method violates its
general contract!
at java.util.ComparableTimSort.mergeLo(Unknown Source)
at java.util.ComparableTimSort.mergeAt(Unknown Source)
at java.util.ComparableTimSort.mergeForceCollapse(Unknown Source)
at java.util.ComparableTimSort.sort(Unknown Source)
at java.util.ComparableTimSort.sort(Unknown Source)
at java.util.Arrays.sort(Unknown Source)
at java.util.Collections.sort(Unknown Source)
at
net.rptools.maptool.client.ui.zone.FogUtil.calculateVisibility(FogUtil.java:81)
at
net.rptools.maptool.client.ui.zone.ZoneView.calculateLightSourceArea(ZoneView.java:142)
at
net.rptools.maptool.client.ui.zone.ZoneView.calculatePersonalLightSourceArea(ZoneView.java:123)
at
net.rptools.maptool.client.ui.zone.ZoneView.getVisibleArea(ZoneView.java:251)
at
net.rptools.maptool.client.ui.zone.ZoneView.calculateVisibleArea(ZoneView.java:429)
at
net.rptools.maptool.client.ui.zone.ZoneView.getVisibleArea(ZoneView.java:63)
at
net.rptools.maptool.client.ui.zone.ZoneRenderer.renderZone(ZoneRenderer.java:956)
at
net.rptools.maptool.client.ui.zone.ZoneRenderer.paintComponent(ZoneRenderer.java:680)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintChildren(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown
Source)
at javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
at javax.swing.RepaintManager.paint(Unknown Source)
at javax.swing.JComponent._paintImmediately(Unknown Source)
at javax.swing.JComponent.paintImmediately(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
at javax.swing.RepaintManager.access$700(Unknown Source)
at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at
net.rptools.maptool.client.swing.MapToolEventQueue.dispatchEvent(MapToolEventQueue.java:38)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.WaitDispatchSupport$2.run(Unknown Source)
at java.awt.WaitDispatchSupport$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.WaitDispatchSupport.enter(Unknown Source)
at java.awt.Dialog.show(Unknown Source)
at java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
at java.awt.Window.setVisible(Unknown Source)
at java.awt.Dialog.setVisible(Unknown Source)
at
net.rptools.maptool.client.swing.MapToolEventQueue.displayPopup(MapToolEventQueue.java:57)
at
net.rptools.maptool.client.swing.MapToolEventQueue.dispatchEvent(MapToolEventQueue.java:48)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.WaitDispatchSupport$2.run(Unknown Source)
at java.awt.WaitDispatchSupport$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.WaitDispatchSupport.enter(Unknown Source)
at java.awt.Dialog.show(Unknown Source)
at java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
at java.awt.Window.setVisible(Unknown Source)
at java.awt.Dialog.setVisible(Unknown Source)
at
net.rptools.maptool.client.swing.MapToolEventQueue.displayPopup(MapToolEventQueue.java:57)
at
net.rptools.maptool.client.swing.MapToolEventQueue.dispatchEvent(MapToolEventQueue.java:48)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.WaitDispatchSupport$2.run(Unknown Source)
at java.awt.WaitDispatchSupport$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.WaitDispatchSupport.enter(Unknown Source)
at java.awt.Dialog.show(Unknown Source)
at java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
at java.awt.Window.setVisible(Unknown Source)
at java.awt.Dialog.setVisible(Unknown Source)
at
net.rptools.maptool.client.swing.MapToolEventQueue.displayPopup(MapToolEventQueue.java:57)
at
net.rptools.maptool.client.swing.MapToolEventQueue.dispatchEvent(MapToolEventQueue.java:48)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.WaitDispatchSupport$2.run(Unknown Source)
at java.awt.WaitDispatchSupport$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.WaitDispatchSupport.enter(Unknown Source)
at java.awt.Dialog.show(Unknown Source)
at java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
at java.awt.Window.setVisible(Unknown Source)
at java.awt.Dialog.setVisible(Unknown Source)
at
net.rptools.maptool.client.swing.MapToolEventQueue.displayPopup(MapToolEventQueue.java:57)
at
net.rptools.maptool.client.swing.MapToolEventQueue.dispatchEvent(MapToolEventQueue.java:48)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.WaitDispatchSupport$2.run(Unknown Source)
at java.awt.WaitDispatchSupport$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.WaitDispatchSupport.enter(Unknown Source)
at java.awt.Dialog.show(Unknown Source)
at java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
at java.awt.Window.setVisible(Unknown Source)
at java.awt.Dialog.setVisible(Unknown Source)
at
net.rptools.maptool.client.swing.MapToolEventQueue.displayPopup(MapToolEventQueue.java:57)
at
net.rptools.maptool.client.swing.MapToolEventQueue.dispatchEvent(MapToolEventQueue.java:48)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.WaitDispatchSupport$2.run(Unknown Source)
at java.awt.WaitDispatchSupport$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.WaitDispatchSupport.enter(Unknown Source)
at java.awt.Dialog.show(Unknown Source)
at java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
at java.awt.Window.setVisible(Unknown Source)
at java.awt.Dialog.setVisible(Unknown Source)
at
net.rptools.maptool.client.functions.InputFunction.childEvaluate(InputFunction.java:1037)
at
net.rptools.parser.function.AbstractFunction.evaluate(AbstractFunction.java:50)
at
net.rptools.parser.EvaluationTreeParser.evaluate(EvaluationTreeParser.java:115)
at
net.rptools.parser.EvaluationTreeParser.evaluate(EvaluationTreeParser.java:107)
at net.rptools.parser.Expression.evaluate(Expression.java:55)
at
net.rptools.common.expression.ExpressionParser.evaluate(ExpressionParser.java:181)
at
net.rptools.maptool.client.MapToolLineParser.parseExpression(MapToolLineParser.java:1278)
at
net.rptools.maptool.client.MapToolLineParser.parseLine(MapToolLineParser.java:1135)
at
net.rptools.maptool.client.MapToolLineParser.runMacroBlock(MapToolLineParser.java:1524)
at
net.rptools.maptool.client.MapToolLineParser.runMacro(MapToolLineParser.java:1455)
at
net.rptools.maptool.client.MapToolLineParser.runMacro(MapToolLineParser.java:1336)
at
net.rptools.maptool.client.MapToolLineParser.parseLine(MapToolLineParser.java:1190)
at
net.rptools.maptool.client.MapToolLineParser.parseLine(MapToolLineParser.java:607)
at
net.rptools.maptool.client.macro.MacroManager.executeMacro(MacroManager.java:213)
at
net.rptools.maptool.client.macro.impl.ImpersonateMacro.execute(ImpersonateMacro.java:72)
at
net.rptools.maptool.client.macro.MacroManager.executeMacro(MacroManager.java:375)
at
net.rptools.maptool.client.macro.MacroManager.executeMacro(MacroManager.java:221)
at
net.rptools.maptool.client.ui.commandpanel.CommandPanel.commitCommand(CommandPanel.java:494)
at
net.rptools.maptool.model.MacroButtonProperties.executeCommand(MacroButtonProperties.java:419)
at
net.rptools.maptool.model.MacroButtonProperties.executeMacro(MacroButtonProperties.java:326)
at
net.rptools.maptool.client.ui.macrobuttons.buttons.MacroButton.mouseReleased(MacroButton.java:191)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at
net.rptools.maptool.client.swing.MapToolEventQueue.dispatchEvent(MapToolEventQueue.java:38)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

-Avotas
Last edited by Avotas on Sun Oct 23, 2011 9:34 pm, edited 1 time in total.

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: Problem!

Post by Rumble »

What version of Java is the player using?

Avotas
Cave Troll
Posts: 76
Joined: Mon Nov 22, 2010 8:42 am

Re: Problem!

Post by Avotas »

Java 7, 64 Bit.

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: Problem!

Post by Rumble »

Yep, that's probably the problem. From googling that error message, it seems Java 7 is a bit more strict about...something having to do with merging and sorting (I don't understand what, precisely) than Java 6.

Avotas
Cave Troll
Posts: 76
Joined: Mon Nov 22, 2010 8:42 am

Re: Problem!

Post by Avotas »

Thanks for the help!

User avatar
Rumble
Deity
Posts: 6235
Joined: Tue Jul 01, 2008 7:48 pm

Re: Problem! [Java 7 Bug?]

Post by Rumble »

Sure! I saw that there's a command line switch:

Code: Select all

-Djava.util.Arrays.useLegacyMergeSort=true
that is supposed to unstrictify it - your player might try adding that to the MapTool launch batch file, and launch MapTool that way - see if that fixes it.

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: Problem! [Java 7 Bug?]

Post by Azhrei »

Yes, this is Java 7 being stricter than Java 6. (Which is a Good Thing(tm) IMO.)

I have updated the code so that (hopefully) the exception will no longer be thrown. This will be in b88.

User avatar
Flibbles
Kobold
Posts: 4
Joined: Tue May 29, 2012 2:41 am

Re: Problem! [Java 7 Bug?]

Post by Flibbles »

Hello!

I had a friend encounter this issue back on the 87 build and I went about diagnosing it before I saw you put in a fix. But I'm wondering if anyone is still encountering this because I think I may see another problem:

The compareTo method you patched calls "VisibleAreaSegment.getDistanceFromOrigin" which calls "GeometryUtil.getDistance()" in the rplib. The implementation for that is:

Code: Select all

public static double getDistance(Point2D p1, Point2D p2) {
    double a = p2.getX() - p1.getX();
    double b = p2.getY() - p1.getY();
    return Math.abs(Math.sqrt(a+b));
}
Shouldn't "Math.abs(Math.sqrt(a+b))" be "Math.abs(Math.sqrt((a*a)+(b*b)))"?

Otherwise comparing A to B would produce different results than comparing B to A since in one of those cases, you're square rooting a negative number (which the javadocs say should be NaN). This could certainly account for a "Comparison method violates its general contract" exception.

And actually, since the result is just for sorting, might it be better just to forgo the sqrt and just compare the square of the distances? It might be a bit faster and suffer a bit less round-off error.

Anyway, sorry I can't be more concrete (the problem was on my friend's computer and he since downgraded to Java 6), but if you're busy and you think I may be on to something, I would be happy to throw together a patch when I have a moment.

Cheers!

username
Dragon
Posts: 277
Joined: Sun Sep 04, 2011 7:01 am

Re: Problem! [Java 7 Bug?]

Post by username »

I don't have access to the code right now. But the code you quote is so utterly false that I wonder why this hasn't fallen apart earlier. I can only guess that it is used almost never. In particular, there is a method in the Point class to give the distance to another point.

User avatar
Flibbles
Kobold
Posts: 4
Joined: Tue May 29, 2012 2:41 am

Re: Problem! [Java 7 Bug?]

Post by Flibbles »

Ah, you are right. In all of the maptool code base it is used twice. Once in that CompareTo method, the other in the class "AreaMeta". If there is another method, perhaps removing it may be a better option? I've actually been looking to contribute. If it's not over-complicating it, I could fix this myself and send a patch.

username
Dragon
Posts: 277
Joined: Sun Sep 04, 2011 7:01 am

Re: Problem! [Java 7 Bug?]

Post by username »

Please remove the code through a patch (post it in some appropriate forum with a reference here). Send it to Azhrei directly as well, since he might not monitor this thread and he is the one that will produce a new version of 1.3 one of these days. b88 is in the queue.

Post Reply

Return to “MapTool”