Skip to content

Commit

Permalink
8311879: SA ClassWriter generates invalid invokedynamic code
Browse files Browse the repository at this point in the history
Reviewed-by: matsaave, cjplummer, coleenp
  • Loading branch information
quadhier authored and plummercj committed Jul 19, 2023
1 parent 6f66213 commit aa23fd9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 0 additions & 3 deletions src/hotspot/share/interpreter/rewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,6 @@ void Rewriter::rewrite_invokedynamic(address bcp, int offset, bool reverse) {
// Should do nothing since we are not patching this bytecode
int cache_index = ConstantPool::decode_invokedynamic_index(
Bytes::get_native_u4(p));
// We will reverse the bytecode rewriting _after_ adjusting them.
// Adjust the cache index by offset to the invokedynamic entries in the
// cpCache plus the delta if the invokedynamic bytecodes were adjusted.
int cp_index = _initialized_indy_entries.at(cache_index).constant_pool_index();
assert(_pool->tag_at(cp_index).is_invoke_dynamic(), "wrong index");
// zero out 4 bytes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2023, 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
Expand Down Expand Up @@ -102,7 +102,9 @@ protected short getConstantPoolIndex(int rawcode, int bci) {
// Invokedynamic require special handling
cpCacheIndex = ~cpCacheIndex;
cpCacheIndex = bytes.swapInt(cpCacheIndex);
return (short) cpCache.getEntryAt(cpCacheIndex).getConstantPoolIndex();
short cpIndex = (short) cpCache.getIndyEntryAt(cpCacheIndex).getConstantPoolIndex();
Assert.that(cpool.getTagAt(cpIndex).isInvokeDynamic(), "CP Entry should be InvokeDynamic");
return cpIndex;
} else if (fmt.contains("JJ")) {
// change byte-ordering and go via cache
return (short) cpCache.getEntryAt((int) (0xFFFF & bytes.swapShort((short)cpCacheIndex))).getConstantPoolIndex();
Expand Down

1 comment on commit aa23fd9

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.