The transformer does not check for use via reflection. The only cases
in the 550 and OSRS clients where methods are accessed via reflection
are either 1) JRE classes, 2) when the method name is sent from the
server.
PSVM and methods declared in TypedRemapper.EXCLUDED_METHODS are never
removed.
The transformer does _not_ check for use via reflection. The only cases
in the 550 and OSRS clients where methods are accessed via reflection
are either 1) JRE classes, 2) when the method name is sent from the
server.
PSVM and methods declared in TypedRemapper.EXCLUDED_METHODS are never
removed.
Signed-off-by: Major <major@emulate.rs>
Finding this logic a little bit hard to follow. Is it to ensure methods which only reference themselves are deleted?
I wonder if val references = methodReferences[partition].minus(member) followed by if (references.isNotEmpty()) { would be clearer? (albeit slightly slower, I expect)
Finding this logic a little bit hard to follow. Is it to ensure methods which only reference themselves are deleted?
I wonder if `val references = methodReferences[partition].minus(member)` followed by `if (references.isNotEmpty()) {` would be clearer? (albeit slightly slower, I expect)
Remove one of these blank lines (I think IDEA's formatter should be configured to only allow a max of one blank line inside method code? I'm not sure if you ran it or not.)
Remove one of these blank lines (I think IDEA's formatter should be configured to only allow a max of one blank line inside method code? I'm not sure if you ran it or not.)
I don't think we need this check, because it will already be covered by "main" being in TypedRemapper.EXCLUDED_METHODS.
(It does mean we remove it anyway regardless of access flags/descriptor, but most of the other code using EXCLUDED_* is like that anyway. And dropping the first condition doesn't change any of that, because it always falls back to the second one.)
I don't think we need this check, because it will already be covered by `"main"` being in `TypedRemapper.EXCLUDED_METHODS`.
(It does mean we remove it anyway regardless of access flags/descriptor, but most of the other code using `EXCLUDED_*` is like that anyway. And dropping the first condition doesn't change any of that, because it always falls back to the second one.)
The transformer does not check for use via reflection. The only cases
in the 550 and OSRS clients where methods are accessed via reflection
are either 1) JRE classes, 2) when the method name is sent from the
server.
PSVM and methods declared in TypedRemapper.EXCLUDED_METHODS are never
removed.
Signed-off-by: Major major@emulate.rs
A few comments, mostly nit-picking
import org.objectweb.asm.tree.MethodNode
class UnusedMethodTransformer : Transformer() {
I'd remove this blank line for consistency with existing classes, where there is no gap
}
val references = methodReferences[partition]
if (references.isNotEmpty() && (references.size != 1 || references.first() != member)) {
Finding this logic a little bit hard to follow. Is it to ensure methods which only reference themselves are deleted?
I wonder if
val references = methodReferences[partition].minus(member)
followed byif (references.isNotEmpty()) {
would be clearer? (albeit slightly slower, I expect)continue
}
val partitionOwners = partition.mapTo(mutableSetOf(), MemberRef::owner)
This variable seems to be unused?
val partitionOwners = partition.mapTo(mutableSetOf(), MemberRef::owner)
partitionOwners -= clazz.name
Remove one of these blank lines (I think IDEA's formatter should be configured to only allow a max of one blank line inside method code? I'm not sure if you ran it or not.)
val owner = library[ref.owner]!!
val superMethods = owner.methods.iterator()
for (superMethod in superMethods) {
Maybe replace with
owner.methods.removeIf { it.name == ref.name && it.desc == ref.desc }
?More concise, and we use
removeIf
similarly elsewhere.}
}
logger.info { "Removed $methodsRemoved unused methods." }
Remove trailing period for consistency with other log messages in the codebase
private fun retain(method: MethodNode): Boolean {
val name = method.name
if (method.access and Opcodes.ACC_STATIC != 0 && name == "main" && method.desc == PSVM_DESCRIPTOR) {
I don't think we need this check, because it will already be covered by
"main"
being inTypedRemapper.EXCLUDED_METHODS
.(It does mean we remove it anyway regardless of access flags/descriptor, but most of the other code using
EXCLUDED_*
is like that anyway. And dropping the first condition doesn't change any of that, because it always falls back to the second one.)488e8ef8c3
.