Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (115)
games submitted by our members
Games in WIP (562)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Does this snippet of code hang your thread?  (Read 1098 times)
0 Members and 1 Guest are viewing this topic.
Offline Jeremy
« Posted 2013-08-10 14:58:35 »

I stumbled upon a series of geometry manipulations that cause the Area.subtract routine to hang (and never return) - which is obviously inappropriate behavior. I was thinking of submitting it as a bug - through some searching, I found someone else who was experiencing the same sort of issue ( http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25400 ) reported in 2005 for JamVM - his algorithm didn't hang my environment. Anyway, here is the code-snippet, tell me if your main thread hangs and if you care to check, your JRE (just because I am curious):

I'm not sure why it hangs, but I do know that it shouldn't - at the very least it should be throwing an exception.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
package UnitTest;

import java.awt.Polygon;
import java.awt.geom.*;

public class Main
{
   
   public static void main(String[] args)
   {

      AffineTransform lightTransform0 = new AffineTransform();
      lightTransform0.translate(192,463);
      lightTransform0.scale(1.0F, 1.0F);

      Ellipse2D ellipse = new Ellipse2D.Float(-192, -96, 384, 192);
      Area lightArea = new Area(ellipse);
      lightArea = lightArea.createTransformedArea(lightTransform0);

      ///////////////////////
     Area obstructionArea = new Area();

      Polygon obstructionPolygon0 = new Polygon();

      obstructionPolygon0.addPoint(176, 384);
      obstructionPolygon0.addPoint(208, 384);
      obstructionPolygon0.addPoint(208, -406);
      obstructionPolygon0.addPoint(176, -406);

      Area obstruction0 = new Area(obstructionPolygon0);
      obstruction0.intersect(lightArea);
      obstruction0.subtract(obstructionArea);
      obstructionArea.add(obstruction0);

      /////////////////////////

      Polygon obstructionPolygon1 = new Polygon();
      obstructionPolygon1.addPoint(96, 479);
      obstructionPolygon1.addPoint(96, 449);

      obstructionPolygon1.addPoint(-864, 459);
      obstructionPolygon1.addPoint(-864, 489);

      Area obstruction1 = new Area(obstructionPolygon1);
      obstruction1.intersect(lightArea);
      obstruction1.subtract(obstructionArea);
      obstructionArea.add(obstruction1);


      //This line should cause a hang!
               //So will lightArea.intersect(obstructionArea);
     lightArea.subtract(obstructionArea);
     
    }
}

JevaEngine, Latest Playthrough (This demo is networked with a centralized server model)

http://www.youtube.com/watch?v=rWA8bajpVXg
Online Riven
« League of Dukes »

JGO Overlord


Medals: 799
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2013-08-10 15:22:40 »

Hangs here too (7u25)

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Jeremy
« Reply #2 - Posted 2013-08-10 17:04:14 »

Hangs here too (7u25)

Thanks. I suspected it would. I'll issue a bug report if I can't find anything recent on it.

The Area subtract routine I find is quite unpredictable - sometimes it takes about half a second to perform the subtraction which is just insane - most of the time it performs very quickly but it seems to arbitrarily and unpredictably screw up like this - I know it will probably take a while before the bug is fixed and rolled out so... I can't use this API. I'm pretty sure though there are faster alternatives out there. I'm looking at JTS now.

JevaEngine, Latest Playthrough (This demo is networked with a centralized server model)

http://www.youtube.com/watch?v=rWA8bajpVXg
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gimbal

JGO Knight


Medals: 25



« Reply #3 - Posted 2013-09-10 07:48:38 »

Also hangs on Java 6 (last update).

The hang is in a class for which I don't have the source handy, in sun.awt.geom.AreaOp, inner class SubOp, method calculate(Vector,Vector)
Offline jonjava
« Reply #4 - Posted 2013-09-10 08:44:00 »

Hangs, 7u25-b16.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (28 views)
2014-09-21 02:42:18

BurntPizza (18 views)
2014-09-21 01:30:30

moogie (19 views)
2014-09-21 00:26:15

UprightPath (27 views)
2014-09-20 20:14:06

BurntPizza (29 views)
2014-09-19 03:14:18

Dwinin (45 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (101 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24:56

mitcheeb (71 views)
2014-09-08 06:06:29
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!