From 8286fe95ee508f9a151e5fd5b27a31cc32bd7344 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Thu, 6 Apr 2017 16:17:03 +0200 Subject: [PATCH] 8178077: jshell tool: crash on ctrl-up or ctrl-down When looking up a private method, using the ConsoleReader.class, instead of getClass(), which may return a subclass. Reviewed-by: rfield --- .../classes/jdk/internal/jline/extra/EditingHistory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java index 394d0eb4096..fcccd9d2523 100644 --- a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java +++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java @@ -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 @@ public abstract class EditingHistory implements History { //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());