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
review (cleanup) boot -> standard JRuby extension loading #5205
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
a51f0dc
[refactor] avoid JRuby.runtime usage (on POSIX) when loading kernel.rb
kares b91cf04
internal helper to set meta-class (avoid booting JI due self-reflect)
kares 98e97ba
setup a convention to boot psych.rb (similar to MRI) wout loading JI
kares daf4be3
[refactor] remove (unused) java_utilities.rb
kares 86ada01
match Thread part from prelude.rb with MRI - likely a bit useless
kares 1262e35
remove (internal) helper that is long overdue by now - no refs around
kares 0fbb2b7
hide `include_class` as private - its been deprecated long enough
kares 1e26f2a
[feat] JRuby way of loading extension - without self reflection
kares 9ad164d
actually, set_meta_class helper is needed on boot - move it under Util
kares 6562590
guess sizes (based on `gem` cmd) to avoid re-hashing (during boot)
kares e17c540
the `require 'date.jar'` already does load the *DateLibrary*
kares d7d3f26
setup require 'securerandom.jar' convention instead of manual loading
kares bc56931
we can avoid org.jruby.platform.Platform load by setting up a const
kares ce7df52
do not pollute Object with Signal details - no such constants on MRI
kares 0572339
cleanup and simplify Signal impl details (perform less init work)
kares b6468f0
let's not boot a deprecated `Thread.exclusive` piece in a prelude.rb
kares 339ec5c
gem prelude - const_def slightly faster + match require 'rubygems.rb'
kares 1fad8e3
[refactor] avoid load_error.rb loading -> this is also native in MRI
kares 683b922
we already do have pp.rb loaded on **prelude.rb** (same as at MRI's)
kares 2cb7e73
redo class_loaded_resources to be (re)usable for jar-dependencies
kares 1ed6185
[refactor] re-arrange jruby/kernel.rb -> delay some with autoloads
kares f155ae3
cleanup - JRubyTypeLibrary class hasn't existed for quite some time
kares 51225b7
Revert "setup a convention to boot psych.rb (similar to MRI) wout loa…
kares c3248dd
GC part already loaded from native -> at least delay JI loading on use
kares 5e2085a
[refactor] minor - no need to copy-array for RubyArray
kares 7bdb76a
[refactor] pass context w internal method; use RubyRange#isExcludeEnd
kares 967c7aa
[refactor] avoid some (iternal) array cp-ing (redundant) nil fill-ing
kares 4ad609e
[refactor] this is a len > 2 most of the time -> alloc array directly
kares File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,13 +42,13 @@ | |
|
||
@JRubyModule(name="Signal") | ||
public class RubySignal { | ||
private final static SignalFacade SIGNALS = getSignalFacade(); | ||
|
||
private final static SignalFacade getSignalFacade() { | ||
private final static SignalFacade SIGNAL_FACADE = initSignalFacade(); | ||
|
||
private final static SignalFacade initSignalFacade() { | ||
try { | ||
Class realFacadeClass = Class.forName("org.jruby.util.SunSignalFacade"); | ||
return (SignalFacade)realFacadeClass.newInstance(); | ||
} catch(Throwable e) { | ||
return org.jruby.util.SunSignalFacade.class.newInstance(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. somehow ended up hitting this |
||
} catch (Throwable e) { | ||
return new NoFunctionalitySignalFacade(); | ||
} | ||
} | ||
|
@@ -72,24 +72,24 @@ public static void createSignal(Ruby runtime) { | |
} | ||
|
||
public static Map<String, Integer> list() { | ||
Map<String, Integer> signals = new HashMap<String, Integer>(); | ||
Map<String, Integer> signals = new HashMap<>(); | ||
|
||
for (Signal s : Signal.values()) { | ||
if (!s.description().startsWith(SIGNAME_PREFIX)) | ||
continue; | ||
if (!RUBY_18_SIGNALS.contains(signmWithoutPrefix(s.description()))) | ||
continue; | ||
String desc = s.description(); | ||
if (!desc.startsWith(SIGNAME_PREFIX)) continue; | ||
|
||
desc = signmWithoutPrefix(desc); | ||
if (!SIGNAME(desc)) continue; | ||
|
||
// replace CLD with CHLD value | ||
int signo = s.intValue(); | ||
if (s == Signal.SIGCLD) | ||
signo = Signal.SIGCHLD.intValue(); | ||
|
||
// omit unsupported signals | ||
if (signo >= 20000) | ||
continue; | ||
if (signo >= 20000) continue; | ||
|
||
signals.put(signmWithoutPrefix(s.description()), signo); | ||
signals.put(desc, signo); | ||
} | ||
|
||
return signals; | ||
|
@@ -119,22 +119,22 @@ public static IRubyObject list(ThreadContext context, IRubyObject recv) { | |
|
||
@JRubyMethod(required = 2, meta = true) | ||
public static IRubyObject __jtrap_kernel(final IRubyObject recv, IRubyObject block, IRubyObject sig) { | ||
return SIGNALS.trap(recv, block, sig); | ||
return SIGNAL_FACADE.trap(recv, block, sig); | ||
} | ||
|
||
@JRubyMethod(required = 1, meta = true) | ||
public static IRubyObject __jtrap_platform_kernel(final IRubyObject recv, IRubyObject sig) { | ||
return SIGNALS.restorePlatformDefault(recv, sig); | ||
return SIGNAL_FACADE.restorePlatformDefault(recv, sig); | ||
} | ||
|
||
@JRubyMethod(required = 1, meta = true) | ||
public static IRubyObject __jtrap_osdefault_kernel(final IRubyObject recv, IRubyObject sig) { | ||
return SIGNALS.restoreOSDefault(recv, sig); | ||
return SIGNAL_FACADE.restoreOSDefault(recv, sig); | ||
} | ||
|
||
@JRubyMethod(required = 1, meta = true) | ||
public static IRubyObject __jtrap_restore_kernel(final IRubyObject recv, IRubyObject sig) { | ||
return SIGNALS.ignore(recv, sig); | ||
return SIGNAL_FACADE.ignore(recv, sig); | ||
} | ||
|
||
@JRubyMethod(required = 1, meta = true) | ||
|
@@ -177,58 +177,58 @@ public static String signmWithoutPrefix(String nm) { | |
return (nm.startsWith(SIGNAME_PREFIX)) ? nm.substring(SIGNAME_PREFIX.length()) : nm; | ||
} | ||
|
||
private static final Set<String> RUBY_18_SIGNALS; | ||
static { | ||
RUBY_18_SIGNALS = new HashSet<String>(); | ||
for (String name : new String[] { | ||
"EXIT", | ||
"HUP", | ||
"INT", | ||
"QUIT", | ||
"ILL", | ||
"TRAP", | ||
"IOT", | ||
"ABRT", | ||
"EMT", | ||
"FPE", | ||
"KILL", | ||
"BUS", | ||
"SEGV", | ||
"SYS", | ||
"PIPE", | ||
"ALRM", | ||
"TERM", | ||
"URG", | ||
"STOP", | ||
"TSTP", | ||
"CONT", | ||
"CHLD", | ||
"CLD", | ||
"TTIN", | ||
"TTOU", | ||
"IO", | ||
"XCPU", | ||
"XFSZ", | ||
"VTALRM", | ||
"PROF", | ||
"WINCH", | ||
"USR1", | ||
"USR2", | ||
"LOST", | ||
"MSG", | ||
"PWR", | ||
"POLL", | ||
"DANGER", | ||
"MIGRATE", | ||
"PRE", | ||
"GRANT", | ||
"RETRACT", | ||
"SOUND", | ||
"INFO", | ||
}) { | ||
RUBY_18_SIGNALS.add(name); | ||
private static boolean SIGNAME(final String name) { | ||
switch (name) { | ||
case "EXIT": | ||
case "HUP" : | ||
case "INT" : | ||
case "QUIT": | ||
case "ILL" : | ||
case "TRAP": | ||
case "IOT" : | ||
case "ABRT": | ||
case "EMT" : | ||
case "FPE" : | ||
case "KILL": | ||
case "BUS" : | ||
case "SEGV": | ||
case "SYS" : | ||
case "PIPE": | ||
case "ALRM": | ||
case "TERM": | ||
case "URG" : | ||
case "STOP": | ||
case "TSTP": | ||
case "CONT": | ||
case "CHLD": | ||
case "CLD" : | ||
case "TTIN": | ||
case "TTOU": | ||
case "IO" : | ||
case "XCPU": | ||
case "XFSZ": | ||
case "PROF": | ||
case "VTALRM": | ||
case "WINCH": | ||
case "USR1": | ||
case "USR2": | ||
case "LOST": | ||
case "MSG" : | ||
case "PWR" : | ||
case "POLL": | ||
case "DANGER": | ||
case "MIGRATE": | ||
case "PRE" : | ||
case "GRANT": | ||
case "RETRACT": | ||
case "SOUND": | ||
case "INFO": | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
private static final String SIGNAME_PREFIX = "SIG"; | ||
}// RubySignal | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
org.jruby.ext.jruby.JRubyTypeLibrary
class was gone for quite some time - as explained in the commit