42 * <p><b>This is NOT part of any supported API.
43 * If you write code that depends on this, you do so at your own risk.
44 * This code and its internal interfaces are subject to change or
45 * deletion without notice.</b>
46 */
47 public class BasicWriter {
48
49 protected BasicWriter(Context context) {
50 lineWriter = LineWriter.instance(context);
51 out = context.get(PrintWriter.class);
52 messages = context.get(Messages.class);
53 if (messages == null)
54 throw new AssertionError();
55 }
56
57 protected Set<AccessFlag> flagsReportUnknown(AccessFlags flags, ClassFileFormatVersion cffv) {
58 return maskToAccessFlagsReportUnknown(flags.flagsMask(), flags.location(), cffv);
59 }
60
61 protected Set<AccessFlag> maskToAccessFlagsReportUnknown(int mask, AccessFlag.Location location, ClassFileFormatVersion cffv) {
62 try {
63 return AccessFlag.maskToAccessFlags(mask, location, cffv);
64 } catch (IllegalArgumentException ex) {
65 mask &= location.flagsMask(cffv);
66 report("Access Flags: " + ex.getMessage());
67 return AccessFlag.maskToAccessFlags(mask, location, cffv);
68 }
69 }
70
71 protected void print(String s) {
72 lineWriter.print(s);
73 }
74
75 protected void print(Object o) {
76 lineWriter.print(o == null ? null : o.toString());
77 }
78
79 protected void print(Supplier<Object> safeguardedCode) {
80 try {
81 print(safeguardedCode.get());
|
42 * <p><b>This is NOT part of any supported API.
43 * If you write code that depends on this, you do so at your own risk.
44 * This code and its internal interfaces are subject to change or
45 * deletion without notice.</b>
46 */
47 public class BasicWriter {
48
49 protected BasicWriter(Context context) {
50 lineWriter = LineWriter.instance(context);
51 out = context.get(PrintWriter.class);
52 messages = context.get(Messages.class);
53 if (messages == null)
54 throw new AssertionError();
55 }
56
57 protected Set<AccessFlag> flagsReportUnknown(AccessFlags flags, ClassFileFormatVersion cffv) {
58 return maskToAccessFlagsReportUnknown(flags.flagsMask(), flags.location(), cffv);
59 }
60
61 protected Set<AccessFlag> maskToAccessFlagsReportUnknown(int mask, AccessFlag.Location location, ClassFileFormatVersion cffv) {
62 if (cffv == null)
63 cffv = ClassFileFormatVersion.CURRENT_PREVIEW_FEATURES; // Aggressive fallback
64 try {
65 return AccessFlag.maskToAccessFlags(mask, location, cffv);
66 } catch (IllegalArgumentException ex) {
67 mask &= location.flagsMask(cffv);
68 report("Access Flags: " + ex.getMessage());
69 return AccessFlag.maskToAccessFlags(mask, location, cffv);
70 }
71 }
72
73 protected void print(String s) {
74 lineWriter.print(s);
75 }
76
77 protected void print(Object o) {
78 lineWriter.print(o == null ? null : o.toString());
79 }
80
81 protected void print(Supplier<Object> safeguardedCode) {
82 try {
83 print(safeguardedCode.get());
|