-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathTurboClassTransformer.java
More file actions
58 lines (52 loc) · 2.58 KB
/
TurboClassTransformer.java
File metadata and controls
58 lines (52 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* This file is part of FalsePatternLib.
*
* Copyright (C) 2022-2025 FalsePattern
* All Rights Reserved
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* FalsePatternLib is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, only version 3 of the License.
*
* FalsePatternLib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
*/
package com.falsepattern.lib.turboasm;
import org.jetbrains.annotations.NotNull;
/**
* A simple transformer that takes in class bytes and outputs different class bytes.
* It should be thread-safe, and not change class names. It should also have a public no-arguments constructor.
*/
public interface TurboClassTransformer {
/**
* @return The user-friendly owner name of this transformer. Usually a mod id.
*/
String owner();
/**
* @return The user-friendly name of this transformer. Used in logs.
*/
String name();
/**
* A fast scanning function that is used to determine if class transformations should be skipped altogether (if all transformers return false).
* @param className The name of the transformed class (in the dot-separated format).
* @param classNode The handle to the class data and parsed metadata, try to avoid triggering the lazy ASM parse if possible for performance.
* @return true if the class will be transformed by this class transformer.
*/
boolean shouldTransformClass(@NotNull String className, @NotNull ClassNodeHandle classNode);
/**
* (Optionally) transform a given class. No ClassReader flags are used for maximum efficiency, so stack frames are not expanded.
* @param className The name of the transformed class (in the dot-separated format).
* @param classNode The handle to the lazily ASM-parsed class to modify, and metadata used for class writing.
* @return True if the class has been modified in any way by this transformer. If all transformers return false,
* then the ClassNode instance will not be re-serialized.
*/
boolean transformClass(@NotNull String className, @NotNull ClassNodeHandle classNode);
}