import java.util.LinkedList; import java.util.List; import javafx.application.Application; import javafx.beans.property.ListProperty; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleListProperty; import javafx.beans.property.SimpleObjectProperty; import javafx.collections.FXCollections; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.stage.Stage; import javafx.util.Duration; /** Attempt to replicate a JVM crash */ public class CrashJVMTest extends Application { public static class Segment { private ObjectProperty start = new SimpleObjectProperty<>(this, "start", Duration.ZERO); private ObjectProperty end = new SimpleObjectProperty<>(this, "end", Duration.ZERO); public Segment(Duration start, Duration end) { this.start.set(start); this.end.set(end); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof Segment)) { return false; } Segment other = (Segment) obj; if (end == null) { if (other.end != null) { return false; } } else if (!end.equals(other.end)) { return false; } if (start == null) { if (other.start != null) { return false; } } else if (!start.equals(other.start)) { return false; } return true; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((end == null) ? 0 : end.hashCode()); result = prime * result + ((start == null) ? 0 : start.hashCode()); return result; } } private ListProperty list = new SimpleListProperty<>(); /** * {@inheritDoc} * @see javafx.application.Application#init() */ @Override public void init() throws Exception { List stuff = new LinkedList<>(); for(int i = 0; i < 10; i++) { stuff.add(new Segment(Duration.seconds(i), Duration.seconds(i+1))); } list.set(FXCollections.observableList(stuff)); } @Override public void start(Stage s) throws Exception { Button b = new Button("Press Me if you Dare"); b.setOnAction(new EventHandler() { @Override public void handle(ActionEvent arg0) { Segment s1 = new Segment(Duration.seconds(5), Duration.seconds(6)); int val = list.indexOf(s1); System.out.println("Index: " + val); } }); Scene scene = new Scene(b); s.setScene(scene); s.sizeToScene(); s.show(); } public static void main(String[] args) { Application.launch(); } }