public static Path getDisassemblerFilePath()

in core/src/main/java/org/adoptopenjdk/jitwatch/util/DisassemblyUtil.java [108:191]


	public static Path getDisassemblerFilePath()
	{
		String binaryName = getDisassemblerFilename();

		// first check the dynamic library path in case user has overridden JDK location for hsdis
		String dynLibPath = System.getenv(getDynamicLibraryPath());

		if (dynLibPath != null)
		{
			String[] dirs = dynLibPath.split(":");

			for (String dir : dirs)
			{
				Path path = Paths.get(dir, binaryName);

				if (DEBUG_LOGGING_ASSEMBLY)
				{
					logger.debug("looking in {}", path);
				}

				File file = path.toFile();

				if (file.exists() && file.isFile())
				{
					return path;
				}
			}
		}

		// next search JDK
		String javaHome = System.getProperty("java.home", "");

		if (DEBUG_LOGGING_ASSEMBLY)
		{
			logger.debug("java.home is {}", javaHome);
		}

		if (javaHome.endsWith("jre"))
		{
			javaHome = javaHome.substring(0, javaHome.length() - 3);
		}

		String[] jrePath = new String[] { "jre", "" };

		String[] libPath = new String[] { "lib", "bin", "" };

		String[] serverPath = new String[] { "server", "client", "" };

		String[] archPath = new String[] { "i386", "amd64", "arm", "aarch64", "" };

		for (String jre : jrePath)
		{
			for (String lib : libPath)
			{
				for (String server : serverPath)
				{
					for (String arch : archPath)
					{
						Path path = Paths.get(javaHome, jre, lib, server, arch, binaryName);

						if (DEBUG_LOGGING_ASSEMBLY)
						{
							logger.debug("looking in {}", path);
						}

						File file = path.toFile();

						if (file.exists() && file.isFile())
						{
							return path;
						}
					}
				}
			}
		}

		// finally search for locally downloaded
		if (downloadedDisassemblerPresent())
		{
			return Paths.get(getDisassemblerFilename());
		}

		return null;
	}