mojira.dev

xDark

Assigned

No issues.

Reported

MCL-13018 Launcher should not override -Dlog4j.configurationFile property Duplicate

Comments

I have made a code snippet that tries to fix this issue:

import java.io.UncheckedIOException;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

public final class FixedClassLoader extends URLClassLoader {
    private static final String ENCODED_SEP;

    public FixedClassLoader(URL[] urls, ClassLoader parent) {
        super(rewriteUrls(urls), parent);
    }

    @Override
    protected void addURL(URL url) {
        super.addURL(rewriteUrl(url));
    }

    private static URL[] rewriteUrls(URL[] urls) {
        for (int i = 0, j = urls.length; i < j; i++) {
            urls[i] = rewriteUrl(urls[i]);
        }
        return urls;
    }

    private static URL rewriteUrl(URL url) {
        String protocol = url.getProtocol();
        if ("jar".equals(protocol) || "file".equals(protocol)) {
            try {
                return new URL(protocol, url.getHost(), url.getPort(), url.getFile().replace("!", ENCODED_SEP));
            } catch (MalformedURLException ex) {
                throw new UncheckedIOException(ex);
            }
        }
        return url;
    }

    static {
        try {
            ENCODED_SEP = URLEncoder.encode("!", StandardCharsets.UTF_8.name());
        } catch (UnsupportedEncodingException ex) {
            throw new ExceptionInInitializerError(ex);
        }
    }
}

Probably more cases shuold be handled, but this might be a fix.

Your PC username has '!' character. Java applications cannot run correctly under this directory. Either change game directory to a folder that does not contain '!', or create new user. (You cannot just rename the user, name of the folder will remain the same). And of course do not rename user directory manually.