Skip to content

Commit df1f294

Browse files
committed
Deprecate the StableAPI annotations, switch to JB annotations
1 parent 8645d20 commit df1f294

File tree

96 files changed

+1077
-760
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1077
-760
lines changed

README.MD

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ A library for 1.7.10 with lots of useful stuff, licensed under the LGPLv3 licens
22

33
| Package | Contents / Purpose |
44
|-----------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
5-
| [.](src/main/java/com/falsepattern/lib) | StableAPI and DeprecationDetails annotations |
65
| [asm](src/main/java/com/falsepattern/lib/asm) | ASM helper code |
76
| [compat](src/main/java/com/falsepattern/lib/compat) | Code backported from vanilla 1.12.2 |
87
| [config](src/main/java/com/falsepattern/lib/config) | 1.12.2-style annotation-based config library |
@@ -26,8 +25,5 @@ The contents of the [util](src/main/java/com/falsepattern/lib/util) package so f
2625
| [RenderUtil](src/main/java/com/falsepattern/lib/util/RenderUtil.java) | Rendering tools. Currently, the only thing implemented is a way to grab the current partial tick time from the minecraft instance |
2726
| [ResourceUtil](src/main/java/com/falsepattern/lib/util/ResourceUtil.java) | Methods for efficiently retrieving resources from SPECIFIC jar files instead of the entire classpath |
2827

29-
See the [@StableAPI](src/main/java/com/falsepattern/lib/StableAPI.java) annotation's javadoc for more information about
30-
API stability.
31-
3228
The update checker module and the library downloader module can be toggled with the `ENABLE_UPDATE_CHECKER` and
3329
`ENABLE_LIBRARY_DOWNLOADS` booleans in the `falsepatternlib.cfg` config file respectively.

src/main/java/com/falsepattern/lib/DeprecationDetails.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,33 @@
2727
import java.lang.annotation.RetentionPolicy;
2828

2929
/**
30+
* DEPRECATED: Use the jetbrains annotations/jspecify instead!
31+
* <p>
3032
* Used together with {@link Deprecated} to specify when an API was marked stable, and when it was marked for deprecation.
3133
* Deprecated classes MAY be removed after a full deprecation cycle as described inside the {@link StableAPI} javadoc.
34+
* @since 0.10.0
3235
*/
36+
@Deprecated(since = "1.7.0")
3337
@Documented
3438
@Retention(RetentionPolicy.RUNTIME)
35-
@StableAPI(since = "0.10.0")
3639
public @interface DeprecationDetails {
37-
@StableAPI.Expose String deprecatedSince();
40+
String deprecatedSince();
3841

39-
@StableAPI.Expose(since = "0.11.0") String replacement() default "";
42+
/**
43+
* @since 0.11.0
44+
*/
45+
String replacement() default "";
4046

4147
/**
48+
* DEPRECATED: Use the jetbrains annotations/jspecify instead!
49+
* <p>
4250
* This marks an API for removal in a future version.
51+
*
52+
* @since 0.12.0
4353
*/
54+
@Deprecated(since = "1.7.0")
4455
@Documented
4556
@Retention(RetentionPolicy.RUNTIME)
46-
@StableAPI(since = "0.12.0")
4757
@interface RemovedInVersion {
4858
String value();
4959
}

src/main/java/com/falsepattern/lib/StableAPI.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import java.lang.annotation.Target;
2929

3030
/**
31+
* DEPRECATED: Use the jetbrains annotations/jspecify instead!
32+
* <p>
3133
* Anything annotated with this annotation will be considered stable, and the class/method/field will not get breaking
3234
* changes without a full deprecation cycle.
3335
* <p>
@@ -52,18 +54,21 @@
5254
* is highly experimental and may be removed or change at any time, however, using it in third party projects is not an
5355
* error, unlike __INTERNAL__, but if any issues arise from the usage of the API or the API changing, the API developer
5456
* shall not be blamed for it.
57+
* @since 0.6.0
5558
*/
59+
@Deprecated(since = "1.7.0")
5660
@Documented
5761
@Retention(RetentionPolicy.RUNTIME)
5862
@Target(ElementType.TYPE)
59-
@StableAPI(since = "0.6.0")
6063
public @interface StableAPI {
6164
/**
6265
* The version this API was introduced/stabilized in. Used for library version tracking.
6366
*/
64-
@StableAPI.Expose String since();
67+
String since();
6568

6669
/**
70+
* DEPRECATED: Use the jetbrains annotations/jspecify instead!
71+
* <p>
6772
* You may use this annotation if you want a member to have an equal effective {@link #since()} value as its owner
6873
* class.
6974
* <p>
@@ -72,24 +77,30 @@
7277
* <p>
7378
* Also note that this only works for class members (methods and fields),
7479
* inner classes still need to use {@link StableAPI}.
80+
*
81+
* @since 0.10.0
7582
*/
83+
@Deprecated(since = "1.7.0")
7684
@Documented
7785
@Retention(RetentionPolicy.RUNTIME)
7886
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
79-
@StableAPI(since = "0.10.0")
8087
@interface Expose {
81-
@StableAPI.Expose String since() default "__PARENT__";
88+
String since() default "__PARENT__";
8289
}
8390

8491
/**
92+
* DEPRECATED: Use the jetbrains annotations/jspecify instead!
93+
* <p>
8594
* Use this if you want to explicitly mark specific members of a {@link StableAPI} class as internal-use only.
8695
* <p>
8796
* Library consumers should never use class members marked with this annotation, as said members can be freely
8897
* changed or removed in any version in the library without prior notice.
98+
*
99+
* @since 0.10.0
89100
*/
101+
@Deprecated(since = "1.7.0")
90102
@Documented
91103
@Retention(RetentionPolicy.RUNTIME)
92104
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
93-
@StableAPI(since = "0.10.0")
94105
@interface Internal {}
95106
}

src/main/java/com/falsepattern/lib/asm/ASMUtil.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
*/
2222
package com.falsepattern.lib.asm;
2323

24-
import com.falsepattern.lib.StableAPI;
2524
import com.falsepattern.lib.asm.exceptions.AsmClassNotFoundException;
2625
import com.falsepattern.lib.asm.exceptions.AsmFieldNotFoundException;
2726
import com.falsepattern.lib.asm.exceptions.AsmMethodNotFoundException;
@@ -44,9 +43,7 @@
4443
import java.util.Arrays;
4544
import java.util.Objects;
4645

47-
@StableAPI(since = "0.10.0")
4846
public class ASMUtil {
49-
@StableAPI.Expose
5047
public static FieldNode findFieldStandard(ClassNode cn, String name, boolean optional) {
5148
for (final FieldNode ret : cn.fields) {
5249
if (name.equals(ret.name)) {
@@ -60,7 +57,6 @@ public static FieldNode findFieldStandard(ClassNode cn, String name, boolean opt
6057
}
6158

6259
@SneakyThrows
63-
@StableAPI.Expose
6460
public static FieldNode findFieldFromMCP(ClassNode cn, String fieldName, boolean optional) {
6561
val classMapping = discoverClassMappingType(cn);
6662
if (classMapping == null) {
@@ -76,7 +72,6 @@ public static FieldNode findFieldFromMCP(ClassNode cn, String fieldName, boolean
7672
optional);
7773
}
7874

79-
@StableAPI.Expose
8075
public static FieldNode findFieldFromUniversal(ClassNode cn, UniversalField field, boolean optional) {
8176
String[] possibilities = CoreLoadingPlugin.isObfuscated() ? new String[]{field.getName(MappingType.SRG),
8277
field.getName(MappingType.Notch)}
@@ -93,7 +88,6 @@ public static FieldNode findFieldFromUniversal(ClassNode cn, UniversalField fiel
9388
possibilities.length == 1 ? possibilities[0] : Arrays.toString(possibilities));
9489
}
9590

96-
@StableAPI.Expose
9791
public static MethodNode findMethodStandard(ClassNode cn, String name, String descriptor, boolean optional) {
9892
for (final MethodNode ret : cn.methods) {
9993
if (name.equals(ret.name) && descriptor.equals(ret.desc)) {
@@ -107,7 +101,6 @@ public static MethodNode findMethodStandard(ClassNode cn, String name, String de
107101
}
108102

109103
@SneakyThrows
110-
@StableAPI.Expose
111104
public static MethodNode findMethodFromMCP(ClassNode cn, String mcpName, String mcpDescriptor, boolean optional) {
112105
val classMapping = discoverClassMappingType(cn);
113106
if (classMapping == null) {
@@ -121,7 +114,6 @@ public static MethodNode findMethodFromMCP(ClassNode cn, String mcpName, String
121114
return findMethodStandard(cn, method.getName(classMapping), method.getDescriptor(classMapping), optional);
122115
}
123116

124-
@StableAPI.Expose
125117
public static MethodNode findMethodFromUniversal(ClassNode cn, UniversalMethod method, boolean optional) {
126118
String[] possibleNames = CoreLoadingPlugin.isObfuscated() ? new String[]{method.getName(MappingType.SRG),
127119
method.getName(MappingType.Notch)}
@@ -142,7 +134,6 @@ public static MethodNode findMethodFromUniversal(ClassNode cn, UniversalMethod m
142134
possibleDescriptors.length == 1 ? possibleDescriptors[0] : Arrays.toString(possibleDescriptors));
143135
}
144136

145-
@StableAPI.Expose
146137
public static MappingType discoverClassMappingType(ClassNode cn) {
147138
if (!CoreLoadingPlugin.isObfuscated()) {
148139
if (MappingManager.containsClass(NameType.Internal, MappingType.MCP, cn.name)) {
@@ -156,7 +147,6 @@ public static MappingType discoverClassMappingType(ClassNode cn) {
156147
return null;
157148
}
158149

159-
@StableAPI.Expose
160150
public static UniversalClass toUniversalClass(ClassNode cn) {
161151
if (!CoreLoadingPlugin.isObfuscated()) {
162152
try {
@@ -177,22 +167,19 @@ public static UniversalClass toUniversalClass(ClassNode cn) {
177167
}
178168
}
179169

180-
@StableAPI.Expose
181170
public static ClassNode parseClass(byte[] bytes, int readerFlags) {
182171
val cn = new ClassNode(Opcodes.ASM5);
183172
val reader = new ClassReader(bytes);
184173
reader.accept(cn, readerFlags);
185174
return cn;
186175
}
187176

188-
@StableAPI.Expose
189177
public static byte[] serializeClass(ClassNode cn, int writerFlags) {
190178
val writer = new ClassWriter(writerFlags);
191179
cn.accept(writer);
192180
return writer.toByteArray();
193181
}
194182

195-
@StableAPI.Expose
196183
public static boolean anyEquals(String str, String... options) {
197184
for (val option : options) {
198185
if (Objects.equals(str, option)) {

src/main/java/com/falsepattern/lib/asm/IClassNodeTransformer.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,21 @@
2121
*/
2222
package com.falsepattern.lib.asm;
2323

24-
import com.falsepattern.lib.DeprecationDetails;
25-
import com.falsepattern.lib.StableAPI;
2624
import org.objectweb.asm.tree.ClassNode;
2725

2826
/**
2927
* See: {@link com.falsepattern.lib.turboasm.TurboClassTransformer}.
3028
* This class will not be removed, for backwards compatibility reasons.
3129
*/
32-
@StableAPI(since = "0.10.0")
33-
@Deprecated
34-
@DeprecationDetails(deprecatedSince = "1.2.0")
30+
@Deprecated(since = "1.2.0")
3531
public interface IClassNodeTransformer {
36-
@StableAPI.Expose
3732
String getName();
3833

39-
@StableAPI.Expose
4034
boolean shouldTransform(ClassNode cn, String transformedName, boolean obfuscated);
4135

42-
@StableAPI.Expose
4336
default int internalSortingOrder() {
4437
return 0;
4538
}
4639

47-
@StableAPI.Expose
4840
void transform(ClassNode cn, String transformedName, boolean obfuscated);
4941
}

src/main/java/com/falsepattern/lib/asm/SmartTransformer.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
*/
2222
package com.falsepattern.lib.asm;
2323

24-
import com.falsepattern.lib.DeprecationDetails;
25-
import com.falsepattern.lib.StableAPI;
2624
import com.falsepattern.lib.internal.asm.CoreLoadingPlugin;
2725
import lombok.val;
2826
import org.apache.logging.log4j.Logger;
@@ -39,14 +37,10 @@
3937
* See: {@link com.falsepattern.lib.turboasm.MergeableTurboTransformer}.
4038
* This class will not be removed, for backwards compatibility reasons.
4139
*/
42-
@StableAPI(since = "0.10.0")
43-
@Deprecated
44-
@DeprecationDetails(deprecatedSince = "1.2.0")
40+
@Deprecated(since = "1.2.0")
4541
public interface SmartTransformer extends IClassTransformer {
46-
@StableAPI.Expose
4742
Logger logger();
4843

49-
@StableAPI.Expose
5044
List<IClassNodeTransformer> transformers();
5145

5246
@Override

src/main/java/com/falsepattern/lib/asm/exceptions/AsmClassNotFoundException.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
*/
2222
package com.falsepattern.lib.asm.exceptions;
2323

24-
import com.falsepattern.lib.StableAPI;
24+
import org.jetbrains.annotations.ApiStatus;
2525

26-
@StableAPI(since = "0.10.0")
2726
public class AsmClassNotFoundException extends AsmTransformException {
28-
@StableAPI.Internal
27+
@ApiStatus.Internal
2928
public AsmClassNotFoundException(final String clazz) {
3029
super("can't find class " + clazz);
3130
}

src/main/java/com/falsepattern/lib/asm/exceptions/AsmFieldNotFoundException.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121
*/
2222
package com.falsepattern.lib.asm.exceptions;
2323

24-
import com.falsepattern.lib.StableAPI;
24+
import org.jetbrains.annotations.ApiStatus;
2525

26-
@StableAPI(since = "0.10.0")
2726
public class AsmFieldNotFoundException extends AsmTransformException {
28-
@StableAPI.Internal
27+
@ApiStatus.Internal
2928
public AsmFieldNotFoundException(final String field) {
3029
super("can't find field " + field);
3130
}

src/main/java/com/falsepattern/lib/asm/exceptions/AsmMethodNotFoundException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
*/
2222
package com.falsepattern.lib.asm.exceptions;
2323

24-
import com.falsepattern.lib.StableAPI;
24+
import org.jetbrains.annotations.ApiStatus;
2525

26-
@StableAPI(since = "0.10.0")
2726
public class AsmMethodNotFoundException extends AsmTransformException {
27+
@ApiStatus.Internal
2828
public AsmMethodNotFoundException(final String method) {
2929
super("can't find method " + method);
3030
}

src/main/java/com/falsepattern/lib/asm/exceptions/AsmTransformException.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,15 @@
2121
*/
2222
package com.falsepattern.lib.asm.exceptions;
2323

24-
import com.falsepattern.lib.StableAPI;
25-
26-
@StableAPI(since = "0.10.0")
2724
public class AsmTransformException extends RuntimeException {
28-
@StableAPI.Expose
2925
public AsmTransformException(final String message) {
3026
super(message);
3127
}
3228

33-
@StableAPI.Expose
3429
public AsmTransformException(final Throwable cause) {
3530
super(cause);
3631
}
3732

38-
@StableAPI.Expose
3933
public AsmTransformException(final String message, final Throwable cause) {
4034
super(message, cause);
4135
}

0 commit comments

Comments
 (0)