Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace native splash with Java implementation #53

Merged
merged 6 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
Institute of Molecular Cell Biology and Genetics.</license.copyrightOwners>
<license.projectName>ImageJ software for multidimensional image processing and analysis.</license.projectName>

<scijava.jvm.version>1.6</scijava.jvm.version>
<scijava.jvm.version>1.8</scijava.jvm.version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? (If we do need this: we can just remove this line, rather than changing it, since 1.8 is the default these days.)
Edit: Oh, it was for the lambda below. I think we should change the code not to use a lambda, and instead be 1.6-compliant. Sorry about that, but it would keep the door open for a smarter launcher that complains when the version of Java is too old, rather than simply exploding.


<architecture.option />
<debug.option />
Expand Down
14 changes: 4 additions & 10 deletions src/main/c/ImageJ.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
#include "file-funcs.h"
#include "java.h"
#include "platform.h"
#include "splash.h"
#include "string-funcs.h"
#include "xalloc.h"

Expand Down Expand Up @@ -198,7 +197,6 @@ static void maybe_reexec_with_correct_lib_path(struct string *java_library_path)
setenv_or_exit("LD_LIBRARY_PATH", java_library_path->buffer, 1);
if (debug)
error("Re-executing with correct library lookup path (%s)", java_library_path->buffer);
hide_splash();
execvp(main_argv_backup[0], main_argv_backup);
die("Could not re-exec with correct library lookup (%d: %s)!", errno, strerror(errno));
#elif defined(__APPLE__)
Expand All @@ -214,7 +212,6 @@ static void maybe_reexec_with_correct_lib_path(struct string *java_library_path)
setenv_or_exit("DYLD_LIBRARY_PATH", java_library_path->buffer, 1);
if (debug)
error("Re-executing with correct library lookup path (%s)", java_library_path->buffer);
hide_splash();
execvp(main_argv_backup[0], main_argv_backup);
die("Could not re-exec with correct library lookup: %d (%s)", errno, strerror(errno));
#endif
Expand Down Expand Up @@ -1206,8 +1203,6 @@ static void try_with_less_memory(long megabytes)
if (debug)
error("Trying with a smaller heap: %s", buffer->buffer);

hide_splash();

#ifdef WIN32
new_argv[0] = dos_path(new_argv[0]);
for (i = 0; i < j; i++)
Expand Down Expand Up @@ -1285,6 +1280,7 @@ static struct options options;
static long megabytes = 0;
static struct string buffer, buffer2, arg, plugin_path;
static int jdb, advanced_gc = 1, debug_gc;
static int splash = 1;
static int allow_multiple, skip_class_launcher, full_class_path;
static int dont_patch_ij1;

Expand Down Expand Up @@ -1499,7 +1495,7 @@ static int handle_one_option2(int *i, int argc, const char **argv)
add_option_string(&options, &arg, 0);
}
else if (!strcmp("--no-splash", argv[*i]))
disable_splash();
splash = 0;
else if (!strcmp("--help", argv[*i]) ||
!strcmp("-h", argv[*i]))
usage();
Expand Down Expand Up @@ -1774,8 +1770,8 @@ static void parse_command_line(void)

maybe_reexec_with_correct_lib_path(java_library_path);

if (!options.dry_run && !options.use_system_jvm && !headless && (is_default_ij1_class(main_class) || !strcmp(default_main_class, main_class)))
show_splash(imagej_launcher_jar);
if (splash && !options.dry_run && !options.use_system_jvm && !headless && (is_default_ij1_class(main_class) || !strcmp(default_main_class, main_class)))
add_option(&options, "-Dimagej.splash=true", 0);

/* set up class path */
if (full_class_path || !strcmp(default_main_class, main_class)) {
Expand Down Expand Up @@ -2197,7 +2193,6 @@ int start_ij(void)
args = prepare_ij_options(env, &options.ij_options);
(*env)->CallStaticVoidMethodA(env, instance,
method, (jvalue *)&args);
hide_splash();
if ((*vm)->DetachCurrentThread(vm))
error("Could not detach current thread");
/* This does not return until ImageJ exits */
Expand Down Expand Up @@ -2249,7 +2244,6 @@ int start_ij(void)
#endif
}
options.java_options.list[0] = buffer->buffer;
hide_splash();
#ifndef WIN32
if (execvp(buffer->buffer, options.java_options.list))
error("Could not launch system-wide Java (%s)", strerror(errno));
Expand Down
2 changes: 0 additions & 2 deletions src/main/c/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include "platform.h"
#include "file-funcs.h"
#include "java.h"
#include "splash.h"
#include "xalloc.h"

#include <fcntl.h>
Expand Down Expand Up @@ -949,7 +948,6 @@ int launch_32bit_on_tiger(int argc, char **argv)
strcpy(argv[0] + offset, match);
return 0;
}
hide_splash();
execv(argv[0], argv);
fprintf(stderr, "Could not execute %s: %d(%s)\n",
argv[0], errno, strerror(errno));
Expand Down
124 changes: 0 additions & 124 deletions src/main/c/splash.c

This file was deleted.

48 changes: 0 additions & 48 deletions src/main/include/splash.h

This file was deleted.

3 changes: 3 additions & 0 deletions src/main/java/net/imagej/launcher/ClassLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public class ClassLauncher {
*/
public static void main(final String[] arguments) {
originalArguments = arguments;
if (Boolean.getBoolean("imagej.splash") || System.getProperty("imagej.splash") == null) {
SplashScreen.show();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be paranoid, but we may want to wrap the SplashScreen.show() with a try { ... } catch (Throwable t) { t.printStackTrace(); } because we really don't want any bugs in the splash screen to prevent ImageJ from starting up.

}
run(arguments);
}

Expand Down
Loading