8178077: jshell tool: crash on ctrl-up or ctrl-down
authorjlahoda
Thu, 06 Apr 2017 16:17:03 +0200
changeset 44539 5633de18d6cb
parent 44538 a603c475d649
child 44540 dbc181a6e4a7
8178077: jshell tool: crash on ctrl-up or ctrl-down Summary: When looking up a private method, using the ConsoleReader.class, instead of getClass(), which may return a subclass. Reviewed-by: rfield
jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java
--- a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java	Thu Apr 06 14:38:15 2017 +0100
+++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java	Thu Apr 06 16:17:03 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -74,7 +74,7 @@
                 //in.resetPromptLine(in.getPrompt(), in.getHistory().current().toString(), -1);
                 //but that would mean more re-writing on the screen, (and prints an additional
                 //empty line), so using setBuffer directly:
-                Method setBuffer = in.getClass().getDeclaredMethod("setBuffer", String.class);
+                Method setBuffer = ConsoleReader.class.getDeclaredMethod("setBuffer", String.class);
 
                 setBuffer.setAccessible(true);
                 setBuffer.invoke(in, in.getHistory().current().toString());