The code below crashes on Win 7 JavaFX 2.0 and Mac OS X 10.6 Java FX 2.0 EA
On Win 7 32 bits under Java 7 it crashes in WebPane.dll
On Mac OS X I get: Invalid memory access of location 0x170 rip=0x11e7c0d67
The culprit is
eng.load("https://graph.facebook.com/me/friends?access_token="+token); in the change listener.
It would be great if somebody can have a look at it since it's a blocker for me.
Dependency on commons-codec 1.3 attached
Kind Regards
Here's the code:
private static final String API_KEY = "100105617934";
private static final String SECRET_KEY = "81f64457a02b7abf6fde109aee7ed5cd";
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Hello World");
WebView view = new WebView();
final WebEngine eng = view.getEngine();
eng.load("https://graph.facebook.com/oauth/authorize?" + "client_id=" +
API_KEY + "&"
+ "redirect_uri=http://www.facebook.com/connect/login_success.html&type=user_agent&display=popup);
final TextField locationField = new TextField("http://www.oracle.com/us/index.html");
locationField.setMaxHeight(Double.MAX_VALUE);
Button goButton = new Button("Go");
goButton.setDefaultButton(true);
EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
eng.load(locationField.getText().startsWith("http://") ? locationField.getText() :
"http://" + locationField.getText());
}
};
goButton.setOnAction(goAction);
locationField.setOnAction(goAction);
eng.locationProperty().addListener(new ChangeListener<String>() {
@Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
locationField.setText(newValue);
if (newValue.startsWith("http://www.facebook.com/connect/login_success.html")) {
URLCodec codec = new URLCodec();
try {
String s = codec.decode(newValue);
String[] splits = s.split(",");
try {
String json = s.substring(s.indexOf('#') + 1, s.length());
System.out.println("JSON = " + json);
String st = URLDecoder.decode(json, "UTF-8");
System.out.println(st);
String params[] = st.split("&");
HashMap<String, String> parmsMap = new HashMap<String, String>();
for (String param : params) {
String temp[] = param.split("=");
parmsMap.put(temp[0], java.net.URLDecoder.decode(temp[1], "UTF-8"));
}
String token = parmsMap.get("access_token");
System.out.println(token);
eng.load("https://graph.facebook.com/me/friends?access_token="+token);
} catch (Exception e) {
}
} catch (DecoderException e) {
}
}
}
});
GridPane grid = new GridPane();
grid.setVgap(5);
grid.setHgap(5);
GridPane.setConstraints(locationField, 0, 0, 1, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.SOMETIMES);
GridPane.setConstraints(goButton,1,0);
GridPane.setConstraints(view, 0, 1, 2, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS);
grid.getColumnConstraints().addAll(
new ColumnConstraints(100, 100, Double.MAX_VALUE, Priority.ALWAYS, HPos.CENTER, true),
new ColumnConstraints(40, 40, 40, Priority.NEVER, HPos.CENTER, true)
);
grid.getChildren().addAll(locationField, goButton, view);
Scene scene = new Scene(grid, 1024, 768);
}
On Win 7 32 bits under Java 7 it crashes in WebPane.dll
On Mac OS X I get: Invalid memory access of location 0x170 rip=0x11e7c0d67
The culprit is
eng.load("https://graph.facebook.com/me/friends?access_token="+token); in the change listener.
It would be great if somebody can have a look at it since it's a blocker for me.
Dependency on commons-codec 1.3 attached
Kind Regards
Here's the code:
private static final String API_KEY = "100105617934";
private static final String SECRET_KEY = "81f64457a02b7abf6fde109aee7ed5cd";
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Hello World");
WebView view = new WebView();
final WebEngine eng = view.getEngine();
eng.load("https://graph.facebook.com/oauth/authorize?" + "client_id=" +
API_KEY + "&"
+ "redirect_uri=http://www.facebook.com/connect/login_success.html&type=user_agent&display=popup);
final TextField locationField = new TextField("http://www.oracle.com/us/index.html");
locationField.setMaxHeight(Double.MAX_VALUE);
Button goButton = new Button("Go");
goButton.setDefaultButton(true);
EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
eng.load(locationField.getText().startsWith("http://") ? locationField.getText() :
"http://" + locationField.getText());
}
};
goButton.setOnAction(goAction);
locationField.setOnAction(goAction);
eng.locationProperty().addListener(new ChangeListener<String>() {
@Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
locationField.setText(newValue);
if (newValue.startsWith("http://www.facebook.com/connect/login_success.html")) {
URLCodec codec = new URLCodec();
try {
String s = codec.decode(newValue);
String[] splits = s.split(",");
try {
String json = s.substring(s.indexOf('#') + 1, s.length());
System.out.println("JSON = " + json);
String st = URLDecoder.decode(json, "UTF-8");
System.out.println(st);
String params[] = st.split("&");
HashMap<String, String> parmsMap = new HashMap<String, String>();
for (String param : params) {
String temp[] = param.split("=");
parmsMap.put(temp[0], java.net.URLDecoder.decode(temp[1], "UTF-8"));
}
String token = parmsMap.get("access_token");
System.out.println(token);
eng.load("https://graph.facebook.com/me/friends?access_token="+token);
} catch (Exception e) {
}
} catch (DecoderException e) {
}
}
}
});
GridPane grid = new GridPane();
grid.setVgap(5);
grid.setHgap(5);
GridPane.setConstraints(locationField, 0, 0, 1, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.SOMETIMES);
GridPane.setConstraints(goButton,1,0);
GridPane.setConstraints(view, 0, 1, 2, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS);
grid.getColumnConstraints().addAll(
new ColumnConstraints(100, 100, Double.MAX_VALUE, Priority.ALWAYS, HPos.CENTER, true),
new ColumnConstraints(40, 40, 40, Priority.NEVER, HPos.CENTER, true)
);
grid.getChildren().addAll(locationField, goButton, view);
Scene scene = new Scene(grid, 1024, 768);
}
- duplicates
-
JDK-8087652 WebView crashes on calling webEngine.load(url) in a webEngine.locationProperty() ChangeListener
- Open
-
JDK-8120035 JavaFX WebView crash when switching URL
- Closed