Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic module name computation has weird behavior #77

Open
Technici4n opened this issue Sep 5, 2024 · 3 comments
Open

Automatic module name computation has weird behavior #77

Technici4n opened this issue Sep 5, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@Technici4n
Copy link
Contributor

File name: mixinextras-neoforge-0.5.0-beta.3.jar.
Expected name (when on the boot layer): mixinextras.neoforge.
SJH name: mixinextras.neoforge.beta._3.

@Technici4n Technici4n added the bug Something isn't working label Sep 5, 2024
@shartte
Copy link
Contributor

shartte commented Sep 5, 2024

Yes, the JDK definitely handles this differently, here's the output of jar --describe-module

No module descriptor found. Derived automatic module.

[email protected] automatic
requires java.base mandated
provides javax.annotation.processing.Processor with com.llamalad7.mixinextras.ap.MixinExtrasAP
contains com.llamalad7.mixinextras
contains com.llamalad7.mixinextras.ap
contains com.llamalad7.mixinextras.ap.expressions
contains com.llamalad7.mixinextras.expression
contains com.llamalad7.mixinextras.expression.impl
contains com.llamalad7.mixinextras.expression.impl.ast.expressions
contains com.llamalad7.mixinextras.expression.impl.ast.identifiers
contains com.llamalad7.mixinextras.expression.impl.flow
contains com.llamalad7.mixinextras.expression.impl.flow.expansion
contains com.llamalad7.mixinextras.expression.impl.flow.postprocessing
contains com.llamalad7.mixinextras.expression.impl.flow.utils
contains com.llamalad7.mixinextras.expression.impl.point
contains com.llamalad7.mixinextras.expression.impl.pool
contains com.llamalad7.mixinextras.expression.impl.utils
contains com.llamalad7.mixinextras.expression.impl.wrapper
contains com.llamalad7.mixinextras.injector
contains com.llamalad7.mixinextras.injector.v2
contains com.llamalad7.mixinextras.injector.wrapmethod
contains com.llamalad7.mixinextras.injector.wrapoperation
contains com.llamalad7.mixinextras.lib.antlr.runtime
contains com.llamalad7.mixinextras.lib.antlr.runtime.atn
contains com.llamalad7.mixinextras.lib.antlr.runtime.dfa
contains com.llamalad7.mixinextras.lib.antlr.runtime.misc
contains com.llamalad7.mixinextras.lib.antlr.runtime.tree
contains com.llamalad7.mixinextras.lib.apache.commons
contains com.llamalad7.mixinextras.lib.apache.commons.builder
contains com.llamalad7.mixinextras.lib.apache.commons.tuple
contains com.llamalad7.mixinextras.lib.grammar.expressions
contains com.llamalad7.mixinextras.lib.gson
contains com.llamalad7.mixinextras.lib.gson.internal
contains com.llamalad7.mixinextras.lib.gson.stream
contains com.llamalad7.mixinextras.lib.semver
contains com.llamalad7.mixinextras.lib.semver.expr
contains com.llamalad7.mixinextras.lib.semver.util
contains com.llamalad7.mixinextras.platform.neoforge
contains com.llamalad7.mixinextras.service
contains com.llamalad7.mixinextras.sugar
contains com.llamalad7.mixinextras.sugar.impl
contains com.llamalad7.mixinextras.sugar.impl.handlers
contains com.llamalad7.mixinextras.sugar.impl.ref
contains com.llamalad7.mixinextras.sugar.impl.ref.generated
contains com.llamalad7.mixinextras.sugar.ref
contains com.llamalad7.mixinextras.transformer
contains com.llamalad7.mixinextras.utils
contains com.llamalad7.mixinextras.versions
contains com.llamalad7.mixinextras.wrapper
contains com.llamalad7.mixinextras.wrapper.factory

@sciwhiz12
Copy link

From local testing, it seems the problem is in JarMetadata#computeNameAndVersion, once the code has matched the potential version:

var mat = DASH_VERSION.matcher(fn);
if (mat.find()) {
var potential = fn.substring(mat.start() + 1);
var ver = safeParseVersion(potential, path.getFileName().toString());
var name = mat.replaceAll("");
return new NameAndVersion(cleanModuleName(name), ver);
} else {
return new NameAndVersion(cleanModuleName(fn), null);
}

As you can see, the mat.replaceAll line removes the version as matched by the pattern (which may not include the full version), not the version as found and detected by safeParseVersion.

Changing the line to fn.replaceAll(ver, "") seems to fix this issue, and brings it more in line with the parsing code in ModulePath#deriveModuleDescriptor which removes from the module name the matched version and everything after it, although I am unsure what other effects it might have.

@shartte
Copy link
Contributor

shartte commented Sep 5, 2024

I have a rewritten version of this in the startup experiments, I believe.
We should see if that performs better and potentially just copy it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants