Jump to content

Compiled MC Ignoring Access Transformer, Manifest Read Error?


Recommended Posts

Posted

I have an access transformer in my mod, and it works perfectly in the developer environment. However, it fails to even load in the compiled copy of the game, causing a prompt IllegalAccessError and crash.

 

Having reverse-engineered the access-transformer loading code, I have been left stumped.

Here is what I get in my loading logs:

  Quote

[15:03:48] [main/DEBUG] [FML/]: Examining for coremod candidacy Reika-1.0.jar

[15:03:48] [main/DEBUG] [FML/]: Not found coremod data in Reika-1.0.jar

 

And here is the code that loads the Access Transformers (collected from CoreModManager.class, ModAccessTransformer.class, and AccessTransformer.class):

 

private static void discoverCoreMods(File mcDir, LaunchClassLoader classLoader)
    {
        FMLRelaunchLog.fine("Discovering coremods");
        File coreMods = setupCoreModDir(mcDir);
        FilenameFilter ff = new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name)
            {
                return name.endsWith(".jar");
            }
        };
        File[] coreModList = coreMods.listFiles(ff);
        File versionedModDir = new File(coreMods, FMLInjectionData.mccversion);
        if (versionedModDir.isDirectory())
        {
            File[] versionedCoreMods = versionedModDir.listFiles(ff);
            coreModList = ObjectArrays.concat(coreModList, versionedCoreMods, File.class);
        }

        coreModList = FileListHelper.sortFileList(coreModList);

        for (File coreMod : coreModList)
        {
            FMLRelaunchLog.fine("Examining for coremod candidacy %s", coreMod.getName());
            JarFile jar = null;
            Attributes mfAttributes;
            try
            {
                jar = new JarFile(coreMod);
                if (jar.getManifest() == null)
                {
                    // Not a coremod and no access transformer list
                    continue;
                }
                ModAccessTransformer.addJar(jar);
                mfAttributes = jar.getManifest().getMainAttributes();
            }
            catch (IOException ioe)
            {
                FMLRelaunchLog.log(Level.ERROR, ioe, "Unable to read the jar file %s - ignoring", coreMod.getName());
                continue;
            }
            finally
            {
                if (jar != null)
                {
                    try
                    {
                        jar.close();
                    }
                    catch (IOException e)
                    {
                        // Noise
                    }
                }
            }
            String cascadedTweaker = mfAttributes.getValue("TweakClass");
            if (cascadedTweaker != null)
            {
                FMLRelaunchLog.info("Loading tweaker %s from %s", cascadedTweaker, coreMod.getName());
                Integer sortOrder = Ints.tryParse(Strings.nullToEmpty(mfAttributes.getValue("TweakOrder")));
                sortOrder = (sortOrder == null ? Integer.valueOf(0) : sortOrder);
                handleCascadingTweak(coreMod, jar, cascadedTweaker, classLoader, sortOrder);
                loadedCoremods.add(coreMod.getName());
                continue;
            }

            String fmlCorePlugin = mfAttributes.getValue("FMLCorePlugin");
            if (fmlCorePlugin == null)
            {
                // Not a coremod
                FMLRelaunchLog.fine("Not found coremod data in %s", coreMod.getName());
                continue;
            }

    public static void addJar(JarFile jar) throws IOException
    {
        AccessTransformer at = new AccessTransformer(jar);
        if (!at.isEmpty())
        {
            embedded.add(at);
        }
    }

    AccessTransformer(JarFile jar) throws IOException
    {
        Manifest manifest = jar.getManifest();
        String atList = manifest.getMainAttributes().getValue("FMLAT");
        if (atList == null) return;
        for (String at : atList.split(" "))
        {
            JarEntry jarEntry = jar.getJarEntry("META-INF/"+at);
            if (jarEntry != null)
            {
                processATFile(new JarByteSource(jar,jarEntry).asCharSource(Charsets.UTF_);
            }
        }
        FMLRelaunchLog.fine("Loaded %d rules from AccessTransformer mod jar file %s\n", modifiers.size(), jar.getName());
    }

 

As you can see by looking at the code, the fact that I get the first line in my console proves it tries to load my file, and the second line shows that the execution makes it to the line

FMLRelaunchLog.fine("Not found coremod data in %s", coreMod.getName());

As you can also see, this line is only reached if jar.getManifest() does not return null.

 

Digging into the instantiation of an AccessTransformer object, it is clear that what is happening is that "atList", the string returned when reading the manifest parameter for "FMLAT", is null, as that is the only thing that would cause the logs to not contain the message "loaded X rules from access transformer...".

 

-----------------------------------------------------------------------------------------------------------------------

So, in short, it is clear that the Manifest file is being found, but the fetch for the FMLAT property returns null.

Yet here is my manifest file:

Manifest-Version: 1.0
FMLAT: DragonAPI_at.cfg

 

I looked into the java documentation, and I found that it says it requires the manifest file be encoded in UTF-8, rather than ANSI (the windows standard). I tried this, and the game fails to even load my jar, instead printing this:

  Quote

[main/ERROR] [FML/]: Unable to read the jar file Reika-1.0.jar - ignoring

java.io.IOException: invalid header field name: Manifest-Version

    at java.util.jar.Attributes.read(Attributes.java:433) ~[?:1.7.0_55]

    at java.util.jar.Manifest.read(Manifest.java:199) ~[?:1.7.0_55]

    at java.util.jar.Manifest.<init>(Manifest.java:69) ~[?:1.7.0_55]

    at java.util.jar.JarFile.getManifestFromReference(JarFile.java:180) ~[?:1.7.0_55]

    at java.util.jar.JarFile.getManifest(JarFile.java:166) ~[?:1.7.0_55]

    at cpw.mods.fml.relauncher.CoreModManager.discoverCoreMods(CoreModManager.java:244) [forge-1.7.10-10.13.0.1180.jar:?]

 

What is going on, and how do I fix it? I have asked multiple people, and so far noone has any idea.

Posted

In some editors you can save in UTF-8 without the bytecode marks at the beginning of the file. It's my observation, however, than ANSI(7-bit ASCII) is a proper subset of UTF-8 and unless you are putting in characters outside the 127 standard ASCII code, UTF-8 is the same as ANSI.

Posted
  On 8/15/2014 at 9:50 PM, sequituri said:

In some editors you can save in UTF-8 without the bytecode marks at the beginning of the file. It's my observation, however, than ANSI(7-bit ASCII) is a proper subset of UTF-8 and unless you are putting in characters outside the 127 standard ASCII code, UTF-8 is the same as ANSI.

I have done nothing unusual with these files, and have tried all three of my text editors: Windows Notepad, Notepad++, and EditPad Lite.

Posted

Upon further debugging, using a custom script to read my mod JAR in the dev environment (not to actually load it, just parse it for display):

	try {
		JarFile f = new JarFile("C:/Users/Reika/Downloads/mmc-stable-win32/MultiMC/instances/1.7 Test/minecraft/mods/Reika-1.0.jar");
		Manifest mf = f.getManifest();
		ReikaJavaLibrary.pConsole(mf.getEntries());
		f.close();
	}
	catch (Exception e) {
		throw new RuntimeException(e);
	}

 

The result is an empty map "{}", with no exceptions being raised. This is obviously the source of my problem, but why is the manifest file found yet not readable!?

 

EDIT:

Further modification and testing, with this horrible block of code (which basically recreates the Manifest reader)

	try {
		String s = "C:/Users/Reika/Downloads/mmc-stable-win32/MultiMC/instances/1.7 Test/minecraft/mods/Reika-1.0.jar";
		JarFile f = new JarFile(s);
		Manifest mf = f.getManifest();
		ReikaJavaLibrary.pConsole(mf.getEntries());
		ZipEntry e = f.getEntry(f.MANIFEST_NAME);
		ReikaJavaLibrary.pConsole(e);
		ZipFile z = new ZipFile(s);
		InputStream is = z.getInputStream(e);
		byte[] data = IOUtils.readFully(is, (int)e.getSize(), true);
		ReikaJavaLibrary.pConsole(Arrays.toString(data));
		ReikaJavaLibrary.pConsole(new String(data));
		ByteArrayInputStream b = new ByteArrayInputStream(data);
		Class clazz = Class.forName("java.util.jar.Manifest$FastInputStream");
		Constructor con = clazz.getDeclaredConstructor(InputStream.class);
		con.setAccessible(true);
		Object fast = con.newInstance(b);
		Class[] params = new Class[] {byte[].class};
		Method readline = clazz.getDeclaredMethod("readLine", params);
		readline.setAccessible(true);
		byte[] buf = new byte[512];
		int ret = (Integer)readline.invoke(fast, buf);
		int count = 0;
		ReikaJavaLibrary.pConsole(count+": "+ret);
		while (ret != -1) {
			count++;
			ret = (Integer)readline.invoke(fast, buf);
			ReikaJavaLibrary.pConsole(count+": "+ret);
		}
		f.close();
		z.close();
	}
	catch (Exception e) {
		throw new RuntimeException(e);
	}

 

And I get what I was expecting!

  Quote

{} of class java.util.HashMap

META-INF/MANIFEST.MF of class java.util.jar.JarFile$JarFileEntry

[77, 97, 110, 105, 102, 101, 115, 116, 45, 86, 101, 114, 115, 105, 111, 110, 58, 32, 49, 46, 48, 13, 10, 70, 77, 76, 65, 84, 58, 32, 68, 114, 97, 103, 111, 110, 65, 80, 73, 95, 97, 116, 46, 99, 102, 103, 13, 10]

Manifest-Version: 1.0

FMLAT: DragonAPI_at.cfg

 

0: 23

1: 25

2: -1

 

So, in other words, it parses the file fine, yet somehow does not build entries??!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Start by following the docs to get a workspace setup: https://docs.minecraftforge.net/en/latest/gettingstarted/ Then poke around some of the tutorials, https://www.mcjty.eu/docs/1.20/ used to be the goto, but not sure if there are any updates for regular forge or not, but if you've brushed up on Java, it will be enough to get you started. Poke around the Minecraft and Forge sources to see how things are done. Read the FAQ for information on how to post code/logs when you run into issues. Share as much info on issues you have as possible. Use github to host projects, chances of someone helping are higher when they can actually see all your code and/or build it themselves. And finally, keep it on the forums, don't direct message people with questions, most people do not provide personal support like that. Also keep in mind forums posts are not always immediately answered, if you're looking for a quicker response, you can always try the Minecraft Forge discord server.
    • Hello, I have a Forge Minecraft sever (I host it at g-portal.com) which has always worked fine and I had no problems, but today it doesn't wanna work anymore. Today I started the server and the status said online, but after a few seconds it said this: "Start failed". And then out of nowhere it restarted itself and the same thing happened again and again and now it's in an infinite loop where it just keeps failing and then restarts. Here's the download link for the server logs: https://www.mediafire.com/file/sq30dgoonjevib1/2025-07-06-1.log/file Does anyone know how to fix this? If yes I would really appreciate help. Best wishes, Gabs1107
    • I'm experiencing a critical issue on a dedicated Arch Linux server running the latest Forge for Minecraft 1.20.1. When a player exits a Nether portal (not enters, and not via /tp) or teleports into the End via portal, the server completely freezes for 1–10 minutes. During this time, all commands are unresponsive, and the game world essentially locks up. This is with watchdog disabled. Environment: OS: Arch Linux (latest packages) Java: OpenJDK 17 (up to date) Forge Version: Latest 1.20.1 (tested multiple versions from the past ~3 months) Mods: None (issue occurs on a clean install) Server Type: Proxmox VM with: 4 virtual cores 64 GB RAM (63 GB allocated via -Xmx and -Xms flags) Observed Behavior: Observed Behavior: The server freezes for 1–10 minutes when: Exiting a Nether portal (entering does not trigger the issue) Entering or exiting the End using a portal Teleporting using commands (e.g., /tp) works only for the Nether; teleporting to the End via command also causes a freeze The issue occurs anywhere in the world, not tied to specific coordinates or builds During the freeze: The server becomes completely unresponsive to all commands and player actions No crash reports, no errors, and no warnings are logged CPU usage remains under 50%, and RAM usage stays around 6–14 GB After 1–10 minutes, the server recovers automatically and resumes normal operation
    • Hey man, I just found this section in your code.  Try to do this: { "parent": "minecraft:item/generated", "textures": { "layer0": "testmod:item/alexandrite" } } This means your png should be named alexandrite.png. Hope it helps  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.