author | sundar |
Tue, 20 Feb 2018 15:25:40 +0530 | |
changeset 48917 | 37beaca49e63 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
1 |
/* |
36526 | 2 |
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
4 |
* |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
10 |
* |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
15 |
* accompanied this code). |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
16 |
* |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
20 |
* |
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
24 |
*/ |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
25 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
26 |
package com.sun.tools.javap; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
27 |
|
2979
ea39317acd3d
6824493: experimental support for additional info for instructions
jjg
parents:
1039
diff
changeset
|
28 |
import java.util.EnumSet; |
862
44f1d401c8f5
4501661: disallow mixing -public, -private, and -protected options at the same time
jjg
parents:
735
diff
changeset
|
29 |
import java.util.HashSet; |
44f1d401c8f5
4501661: disallow mixing -public, -private, and -protected options at the same time
jjg
parents:
735
diff
changeset
|
30 |
import java.util.Set; |
2979
ea39317acd3d
6824493: experimental support for additional info for instructions
jjg
parents:
1039
diff
changeset
|
31 |
|
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
32 |
import com.sun.tools.classfile.AccessFlags; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
33 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
34 |
/* |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
35 |
* Provides access to javap's options, set via the command line |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
36 |
* or JSR 199 API. |
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
37 |
* <p><b>This is NOT part of any supported API. |
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
38 |
* If you write code that depends on this, you do so at your own risk. |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
39 |
* This code and its internal interfaces are subject to change or |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
40 |
* deletion without notice.</b> |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
41 |
*/ |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
42 |
public class Options { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
43 |
public static Options instance(Context context) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
44 |
Options instance = context.get(Options.class); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
45 |
if (instance == null) |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
46 |
instance = new Options(context); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
47 |
return instance; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
48 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
49 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
50 |
protected Options(Context context) { |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
51 |
context.put(Options.class, this); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
52 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
53 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
54 |
/** |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
55 |
* Checks access of class, field or method. |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
56 |
*/ |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
57 |
public boolean checkAccess(AccessFlags flags){ |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
58 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
59 |
boolean isPublic = flags.is(AccessFlags.ACC_PUBLIC); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
60 |
boolean isProtected = flags.is(AccessFlags.ACC_PROTECTED); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
61 |
boolean isPrivate = flags.is(AccessFlags.ACC_PRIVATE); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
62 |
boolean isPackage = !(isPublic || isProtected || isPrivate); |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
63 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
64 |
if ((showAccess == AccessFlags.ACC_PUBLIC) && (isProtected || isPrivate || isPackage)) |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
65 |
return false; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
66 |
else if ((showAccess == AccessFlags.ACC_PROTECTED) && (isPrivate || isPackage)) |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
67 |
return false; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
68 |
else if ((showAccess == 0) && (isPrivate)) |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
69 |
return false; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
70 |
else |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
71 |
return true; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
72 |
} |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
73 |
|
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
74 |
public boolean help; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
75 |
public boolean verbose; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
76 |
public boolean version; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
77 |
public boolean fullVersion; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
78 |
public boolean showFlags; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
79 |
public boolean showLineAndLocalVariableTables; |
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
80 |
public int showAccess; |
22163 | 81 |
public Set<String> accessOptions = new HashSet<>(); |
2979
ea39317acd3d
6824493: experimental support for additional info for instructions
jjg
parents:
1039
diff
changeset
|
82 |
public Set<InstructionDetailWriter.Kind> details = EnumSet.noneOf(InstructionDetailWriter.Kind.class); |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
83 |
public boolean showDisassembled; |
16291
d4249734ecd8
8007052: javap should include the descriptor for a method in verbose mode
jjg
parents:
5847
diff
changeset
|
84 |
public boolean showDescriptors; |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
85 |
public boolean showAllAttrs; |
1038 | 86 |
public boolean showConstants; |
1039 | 87 |
public boolean sysInfo; |
3544
c6d0f086397f
4880672: javap does not output inner interfaces of an interface
jjg
parents:
3377
diff
changeset
|
88 |
public boolean showInnerClasses; |
23106 | 89 |
public int indentWidth = 2; // #spaces per indentWidth level; must be > 0 |
90 |
public int tabColumn = 40; // column number for comments; must be > 0 |
|
36526 | 91 |
public String moduleName; |
727
cb50c1ae7bab
4075303: Use javap to enquire aboput a specific inner class
jjg
parents:
diff
changeset
|
92 |
} |