Skip to content

Commit

Permalink
fix download of hsdis on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswhocodes committed Jan 17, 2022
1 parent f299017 commit eac4d05
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ public static String getDynamicLibraryPath()
public static String getDisassemblerFilename()
{
OperatingSystem os = OSUtil.getOperatingSystem();
Architecture arch = OSUtil.getArchitecture();

if (DEBUG_LOGGING_ASSEMBLY)
String archName = System.getProperty("os.arch");

if ("x86_64".equals(archName))
{
logger.debug("OS: {} Arch: {}", os, arch);
archName = "amd64";
}

String binaryName = "hsdis-" + System.getProperty("os.arch");
String binaryName = "hsdis-" + archName;

if (os != null)
{
Expand Down Expand Up @@ -150,9 +151,9 @@ public static Path getDisassemblerFilePath()

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

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

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

for (String jre : jrePath)
{
Expand Down
19 changes: 14 additions & 5 deletions ui/src/main/java/org/adoptopenjdk/jitwatch/ui/Dialogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,18 @@ public static Response showYesNoDialogNever(Stage owner, String title, String me
vBox.setSpacing(10);
vBox.setPadding(new Insets(10));

int width = Math.max(320, message == null ? 0 : message.length() * 10);
String[] messageParts = message.split("\n");

Scene scene = UserInterfaceUtil.getScene(vBox, width, 80);
int width = 320;

for (String part : messageParts)
{
vBox.getChildren().add(new Label(part));

width = Math.max(width, part.length() * 10);
}

Scene scene = UserInterfaceUtil.getScene(vBox, width, 80+ messageParts.length * 30);

final Dialog dialog = new Dialog(title, owner, scene);

Expand Down Expand Up @@ -177,7 +186,7 @@ public void handle(ActionEvent e)
}
});

BorderPane bp = new BorderPane();
BorderPane borderPane = new BorderPane();

HBox hBox = new HBox();
hBox.setAlignment(Pos.CENTER);
Expand All @@ -186,9 +195,9 @@ public void handle(ActionEvent e)

hBox.getChildren().addAll(btnYes, btnNo, btnNever);

bp.setCenter(hBox);
vBox.getChildren().add(borderPane);

vBox.getChildren().addAll(new Label(message), bp);
borderPane.setCenter(hBox);

dialog.showDialog();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1696,8 +1696,6 @@ public Stage getStageForDialog()
@Override
public void parserSelected(ParserType parserType)
{
logger.info("Selected Parser: {}", parserType);

if (logParser != null)
{
logParser.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ public void checkHsdis()
{
String disassemblerFilename = DisassemblyUtil.getDisassemblerFilename();

log("Looking for disassembler: " + disassemblerFilename);

Path downloadPath = Paths.get(disassemblerFilename);

Path disassemblerPath = DisassemblyUtil.getDisassemblerFilePath();
Expand All @@ -418,15 +420,17 @@ public void checkHsdis()
{
log("Disassembler not found");

String message = "The hsdis plugin " + disassemblerFilename + " could not be found. Would you like to download it?";
String hsdisDownloadUrl = "https://chriswhocodes.com/hsdis/";

String message = "The disassembly plugin " + disassemblerFilename + " could not be found.\n Would you like to download it from "+hsdisDownloadUrl+" ?";

Response response = Dialogs.showYesNoDialogNever(SandboxStage.this, "Download hsdis plugin", message);
Response response = Dialogs.showYesNoDialogNever(SandboxStage.this, "Download disassembly plugin", message);

switch (response)
{
case YES:
{
String url = "https://chriswhocodes.com/hsdis/" + disassemblerFilename;
String url = hsdisDownloadUrl + disassemblerFilename;

log("Downloading hsdis from " + url);

Expand Down

0 comments on commit eac4d05

Please sign in to comment.