mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8156694: javap should render annotations in a friendly way
Reviewed-by: mcimadamore
This commit is contained in:
parent
905ead0ac3
commit
3b8e460a1a
4 changed files with 288 additions and 22 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 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
|
||||
|
@ -253,6 +253,38 @@ public class ConstantWriter extends BasicWriter {
|
|||
}
|
||||
}
|
||||
|
||||
String booleanValue(int constant_pool_index) {
|
||||
ClassFile classFile = classWriter.getClassFile();
|
||||
try {
|
||||
CPInfo info = classFile.constant_pool.get(constant_pool_index);
|
||||
if (info instanceof CONSTANT_Integer_info) {
|
||||
int value = ((CONSTANT_Integer_info) info).value;
|
||||
switch (value) {
|
||||
case 0: return "false";
|
||||
case 1: return "true";
|
||||
}
|
||||
}
|
||||
return "#" + constant_pool_index;
|
||||
} catch (ConstantPool.InvalidIndex e) {
|
||||
return report(e);
|
||||
}
|
||||
}
|
||||
|
||||
String charValue(int constant_pool_index) {
|
||||
ClassFile classFile = classWriter.getClassFile();
|
||||
try {
|
||||
CPInfo info = classFile.constant_pool.get(constant_pool_index);
|
||||
if (info instanceof CONSTANT_Integer_info) {
|
||||
int value = ((CONSTANT_Integer_info) info).value;
|
||||
return String.valueOf((char) value);
|
||||
} else {
|
||||
return "#" + constant_pool_index;
|
||||
}
|
||||
} catch (ConstantPool.InvalidIndex e) {
|
||||
return report(e);
|
||||
}
|
||||
}
|
||||
|
||||
String stringValue(int constant_pool_index) {
|
||||
ClassFile classFile = classWriter.getClassFile();
|
||||
try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue