智慧考勤 v1.0.28版本的 MD5 值为:12729d810518c958a6eb8d5a86a946dd

以下内容为反编译后的 Installer.java 源代码,内容仅作参考


package lombok.installer;

import anet.channel.entity.ConnType;
import com.loc.ag;
import com.zwitserloot.cmdreader.CmdReader;
import com.zwitserloot.cmdreader.Description;
import com.zwitserloot.cmdreader.InvalidCommandLineException;
import com.zwitserloot.cmdreader.Sequential;
import com.zwitserloot.cmdreader.Shorthand;
import java.awt.HeadlessException;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Pattern;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import lombok.Lombok;
import lombok.core.LombokApp;
import lombok.core.SpiLoadUtil;
import lombok.core.Version;
import lombok.installer.OsUtils;
import lombok.patcher.ClassRootFinder;
public class Installer {
    static final URI ABOUT_LOMBOK_URL = URI.create("https://projectlombok.org");
    static final List<IdeLocationProvider> locationProviders;

    static {
        List<IdeLocationProvider> list = new ArrayList<>();
        try {
            for (IdeLocationProvider provider : SpiLoadUtil.findServices(IdeLocationProvider.class)) {
                list.add(provider);
            }
            locationProviders = Collections.unmodifiableList(list);
        } catch (IOException e) {
            throw Lombok.sneakyThrow(e);
        }
    }

    public static List<Pattern> getIdeExecutableNames() {
        List<Pattern> list = new ArrayList<>();
        for (IdeLocationProvider provider : locationProviders) {
            Pattern p = provider.getLocationSelectors();
            if (p != null) {
                list.add(p);
            }
        }
        return list;
    }

    public static IdeLocation tryAllProviders(String location) throws CorruptedIdeLocationException {
        for (IdeLocationProvider provider : locationProviders) {
            IdeLocation loc = provider.create(location);
            if (loc != null) {
                return loc;
            }
        }
        return null;
    }

    public static void autoDiscover(List<IdeLocation> locations, List<CorruptedIdeLocationException> problems) {
        for (IdeLocationProvider provider : locationProviders) {
            provider.findIdes(locations, problems);
        }
    }

    public static boolean isSelf(String jar) {
        String self = ClassRootFinder.findClassRootOfClass(Installer.class);
        if (self == null) {
            return false;
        }
        File a = new File(jar).getAbsoluteFile();
        File b = new File(self).getAbsoluteFile();
        try {
            a = a.getCanonicalFile();
        } catch (IOException unused) {
        }
        try {
            b = b.getCanonicalFile();
        } catch (IOException unused2) {
        }
        return a.equals(b);
    }

    public static class GraphicalInstallerApp extends LombokApp {
        @Override
        public String getAppName() {
            return "installer";
        }

        @Override
        public String getAppDescription() {
            return "Runs the graphical installer tool (default).";
        }

        @Override
        public List<String> getAppAliases() {
            return Arrays.asList("");
        }

        @Override
        public int runApp(List<String> args) throws Exception {
            return Installer.access$0();
        }
    }

    public static class CommandLineInstallerApp extends LombokApp {
        @Override
        public String getAppName() {
            return "install";
        }

        @Override
        public String getAppDescription() {
            return "Runs the 'handsfree' command line scriptable installer.";
        }

        @Override
        public int runApp(List<String> args) throws Exception {
            return Installer.cliInstaller(false, args);
        }
    }

    public static class CommandLineUninstallerApp extends LombokApp {
        @Override
        public String getAppName() {
            return "uninstall";
        }

        @Override
        public String getAppDescription() {
            return "Runs the 'handsfree' command line scriptable uninstaller.";
        }

        @Override
        public int runApp(List<String> args) throws Exception {
            return Installer.cliInstaller(true, args);
        }
    }

    static int access$0() {
        return guiInstaller();
    }

    private static int guiInstaller() {
        int intValue;
        if (OsUtils.getOS() == OsUtils.OS.MAC_OS_X) {
            System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Lombok Installer");
            System.setProperty("com.apple.macos.use-file-dialog-packages", "true");
        }
        try {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        try {
                            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                        } catch (Exception unused) {
                        }
                        new InstallerGUI().show();
                    } catch (HeadlessException unused2) {
                        Installer.printHeadlessInfo();
                    }
                }
            });
            AtomicReference<Integer> atomicReference = InstallerGUI.exitMarker;
            synchronized (atomicReference) {
                ?? r0 = atomicReference;
                while (!Thread.interrupted() && InstallerGUI.exitMarker.get() == null) {
                    try {
                        AtomicReference<Integer> atomicReference2 = InstallerGUI.exitMarker;
                        atomicReference2.wait();
                        r0 = atomicReference2;
                    } catch (InterruptedException unused) {
                        return 1;
                    }
                }
                Integer errCode = InstallerGUI.exitMarker.get();
                intValue = errCode == null ? 1 : errCode.intValue();
            }
            return intValue;
        } catch (HeadlessException unused2) {
            printHeadlessInfo();
            return 1;
        }
    }

    public static class CmdArgs {
        @Description("Specify paths to a location to install/uninstall. Use 'auto' to apply to all automatically discoverable installations.")
        @Sequential
        List<String> path = new ArrayList();
        @Description("Shows this help text")
        @Shorthand({ag.g, "?"})
        boolean help;

        private CmdArgs() {
        }
    }

    public static int cliInstaller(boolean uninstall, List<String> rawArgs) {
        CmdReader<CmdArgs> reader = CmdReader.of(CmdArgs.class);
        try {
            CmdArgs args = reader.make((String[]) rawArgs.toArray(new String[0]));
            if (args.help) {
                System.out.println(generateCliHelp(uninstall, reader));
                return 0;
            } else if (args.path.isEmpty()) {
                System.err.println("ERROR: Nothing to do!");
                System.err.println("--------------------------");
                System.err.println(generateCliHelp(uninstall, reader));
                return 1;
            } else {
                List<IdeLocation> locations = new ArrayList<>();
                List<CorruptedIdeLocationException> problems = new ArrayList<>();
                if (args.path.contains(ConnType.PK_AUTO)) {
                    autoDiscover(locations, problems);
                }
                for (String rawPath : args.path) {
                    if (!rawPath.equals(ConnType.PK_AUTO)) {
                        try {
                            IdeLocation loc = tryAllProviders(rawPath);
                            if (loc != null) {
                                locations.add(loc);
                            } else {
                                problems.add(new CorruptedIdeLocationException("Can't find any IDE at: " + rawPath, null, null));
                            }
                        } catch (CorruptedIdeLocationException e) {
                            problems.add(e);
                        }
                    }
                }
                int validLocations = locations.size();
                for (IdeLocation loc2 : locations) {
                    if (uninstall) {
                        try {
                            loc2.uninstall();
                        } catch (InstallException e2) {
                            if (e2.isWarning()) {
                                System.err.printf("Warning while installing at %s:\n", loc2.getName());
                            } else {
                                System.err.printf("Installation at %s failed:\n", loc2.getName());
                                validLocations--;
                            }
                            System.err.println(e2.getMessage());
                        } catch (UninstallException e3) {
                            if (e3.isWarning()) {
                                System.err.printf("Warning while uninstalling at %s:\n", loc2.getName());
                            } else {
                                System.err.printf("Uninstall at %s failed:\n", loc2.getName());
                                validLocations--;
                            }
                            System.err.println(e3.getMessage());
                        }
                    } else {
                        loc2.install();
                    }
                    PrintStream printStream = System.out;
                    Object[] objArr = new Object[3];
                    objArr[0] = uninstall ? "uninstalled" : "installed";
                    objArr[1] = uninstall ? "from" : "to";
                    objArr[2] = loc2.getName();
                    printStream.printf("Lombok %s %s: %s\n", objArr);
                }
                for (CorruptedIdeLocationException problem : problems) {
                    System.err.println("WARNING: " + problem.getMessage());
                }
                if (validLocations == 0) {
                    System.err.println("WARNING: Zero valid locations found; so nothing was done!");
                    return 0;
                }
                return 0;
            }
        } catch (InvalidCommandLineException e4) {
            System.err.println(e4.getMessage());
            System.err.println("--------------------------");
            System.err.println(generateCliHelp(uninstall, reader));
            return 1;
        }
    }

    private static String generateCliHelp(boolean uninstall, CmdReader<CmdArgs> reader) {
        return reader.generateCommandLineHelp("java -jar lombok.jar " + (uninstall ? "uninstall" : "install"));
    }

    public static void printHeadlessInfo() {
        System.out.printf("About lombok v%s\nLombok makes java better by providing very spicy additions to the Java programming language,such as using @Getter to automatically generate a getter method for any field.\n\nBrowse to %s for more information. To install lombok on Eclipse, re-run this jar file on a graphical computer system - this message is being shown because your terminal is not graphics capable.\nAlternatively, use the command line installer (java -jar lombok.jar install --help).\nIf you are just using 'javac' or a tool that calls on javac, no installation is neccessary; just make sure lombok.jar is in the classpath when you compile. Example:\n\n   java -cp lombok.jar MyCode.java\n", Version.getVersion(), ABOUT_LOMBOK_URL);
    }
}