Skip to content

Commit 012eec1

Browse files
committed
Add missing internal attributes to AttributeVersions lookup
1 parent 3c21e34 commit 012eec1

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed
Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package software.coley.cafedude.classfile.attribute;
22

3-
import software.coley.cafedude.classfile.VersionConstants;
4-
53
import jakarta.annotation.Nonnull;
4+
import software.coley.cafedude.classfile.VersionConstants;
65

76
/**
87
* Attribute relations to class file versions.
@@ -21,7 +20,7 @@ public class AttributeVersions implements AttributeConstants, VersionConstants {
2120
* If the attribute's introduction version is unknown, then {@code -1}.
2221
*/
2322
public static int getIntroducedVersion(@Nonnull String attributeName) {
24-
switch (attributeName) {
23+
return switch (attributeName) {
2524
case CODE:
2625
case CONSTANT_VALUE:
2726
case DEPRECATED:
@@ -31,7 +30,7 @@ public static int getIntroducedVersion(@Nonnull String attributeName) {
3130
case LOCAL_VARIABLE_TABLE:
3231
case SOURCE_FILE:
3332
case SYNTHETIC:
34-
return JAVA1;
33+
yield JAVA1;
3534
case ANNOTATION_DEFAULT:
3635
case ENCLOSING_METHOD:
3736
case LOCAL_VARIABLE_TYPE_TABLE:
@@ -41,39 +40,36 @@ public static int getIntroducedVersion(@Nonnull String attributeName) {
4140
case RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS:
4241
case SIGNATURE:
4342
case SOURCE_DEBUG_EXTENSION:
44-
return JAVA5;
43+
yield JAVA5;
4544
case STACK_MAP_TABLE:
46-
return JAVA6;
45+
yield JAVA6;
46+
case CHARACTER_RANGE_TABLE:
47+
case COMPILATION_ID:
48+
case SOURCE_ID:
4749
case BOOTSTRAP_METHODS:
48-
return JAVA7;
50+
yield JAVA7;
4951
case METHOD_PARAMETERS:
5052
case RUNTIME_INVISIBLE_TYPE_ANNOTATIONS:
5153
case RUNTIME_VISIBLE_TYPE_ANNOTATIONS:
52-
return JAVA8;
54+
yield JAVA8;
5355
case MODULE:
5456
case MODULE_MAIN_CLASS:
5557
case MODULE_PACKAGES:
56-
return JAVA9;
58+
case MODULE_HASHES:
59+
case MODULE_RESOLUTION:
60+
case MODULE_TARGET:
61+
yield JAVA9;
5762
case NEST_HOST:
5863
case NEST_MEMBERS:
59-
return JAVA11;
64+
yield JAVA11;
6065
case RECORD:
6166
// Records first preview in 14
62-
return JAVA14;
67+
yield JAVA14;
6368
case PERMITTED_SUBCLASSES:
6469
// Sealed classes first preview in 15
65-
return JAVA15;
70+
yield JAVA15;
6671
default:
67-
break;
68-
}
69-
// TODO: Research unused attributes?
70-
// - Some of the following items are listed as consts in the compiler, but are nowhere in the spec...
71-
// - CHARACTER_RANGE_TABLE
72-
// - COMPILATION_ID
73-
// - MODULE_HASHES
74-
// - MODULE_RESOLUTION
75-
// - MODULE_TARGET
76-
// - SOURCE_ID
77-
return -1;
72+
yield -1;
73+
};
7874
}
7975
}

0 commit comments

Comments
 (0)