Top Description Inners Fields Constructors Methods
org.jruby

public Class Main

extends Object
Class Inheritance
Known Direct Subclasses
org.jruby.main.PrebootMain
Imports
org.jruby.exceptions.MainExitException, .JumpException, .RaiseException, .ThreadKill, org.jruby.main.PrebootMain, org.jruby.platform.Platform, org.jruby.runtime.ThreadContext, org.jruby.runtime.backtrace.TraceType, org.jruby.runtime.builtin.IRubyObject, org.jruby.util.SafePropertyAccessor, org.jruby.util.cli.OutputStrings, org.jruby.util.log.Logger, .LoggerFactory, java.io.*, java.lang.management.ManagementFactory, .RuntimeMXBean, java.nio.charset.StandardCharsets, java.util.ArrayList, .List, .Map, .Properties

Class used to launch the interpreter. This is the main class as defined in the jruby.mf manifest. It is very basic and does not support yet the same array of switches as the C interpreter. Usage: java -jar jruby.jar [switches] [rubyfile.rb] [arguments] -e 'command' one line of script. Several -e's allowed. Omit [programfile]
Author
jpetersen

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private final RubyInstanceConfig
private static final Logger

Constructor Summary

AccessConstructor and Description
public
public
Main(final InputStream in, final PrintStream out, final PrintStream err)

public
Main()

private
Main(RubyInstanceConfig config, boolean hardExit)

private
Main(boolean hardExit)

Method Summary

Modifier and TypeMethod and Description
private boolean
checkFileSyntax(Ruby runtime, String filename)

private boolean
checkStreamSyntax(Ruby runtime, InputStream in, String filename)

private Main.Status
doCheckSyntax(Ruby runtime, InputStream in, String filename)

private static void
private void
private void
doPrintUsage(boolean force)

private void
private void
private void
private static List<String>
private String
private String
private Main.Status
private Main.Status
handleOutOfMemory(OutOfMemoryError ex)

Print a nicer memory error since Rubyists aren't used to seeing this.

protected static int
handleRaiseException(final RaiseException ex)

This is only used from the main(String[]) path, in which case the err for this run should be System.err.

private Main.Status
handleStackOverflow(StackOverflowError ex)

Print a nicer stack size error since Rubyists aren't used to seeing this.

private static int
private Main.Status
private Main.Status
private static void
public static void
main(String[]
command-line args, provided by the JVM.
args
)

This is the command-line entry point for JRuby, and should ONLY be used by Java when starting up JRuby from a command-line.

public static void
public Main.Status
run(String[] args)

public Main.Status
run()
Deprecated

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

configback to summary
private final RubyInstanceConfig config
LOGback to summary
private static final Logger LOG

Constructor Detail

Mainback to summary
public Main(RubyInstanceConfig config)
Mainback to summary
public Main(final InputStream in, final PrintStream out, final PrintStream err)
Mainback to summary
public Main()
Mainback to summary
private Main(RubyInstanceConfig config, boolean hardExit)
Mainback to summary
private Main(boolean hardExit)

Method Detail

checkFileSyntaxback to summary
private boolean checkFileSyntax(Ruby runtime, String filename)
checkStreamSyntaxback to summary
private boolean checkStreamSyntax(Ruby runtime, InputStream in, String filename)
doCheckSyntaxback to summary
private Main.Status doCheckSyntax(Ruby runtime, InputStream in, String filename) throws RaiseException
doGCJCheckback to summary
private static void doGCJCheck()
doPrintPropertiesback to summary
private void doPrintProperties()
doPrintUsageback to summary
private void doPrintUsage(boolean force)
doSetContextClassLoaderback to summary
private void doSetContextClassLoader(Ruby runtime)
doShowCopyrightback to summary
private void doShowCopyright()
doShowVersionback to summary
private void doShowVersion()
getDotfileDirectoriesback to summary
private static List<String> getDotfileDirectories()
getRubyPagerEnvback to summary
private String getRubyPagerEnv()
getRuntimeFlagValueback to summary
private String getRuntimeFlagValue(String prefix)
handleMainExitback to summary
private Main.Status handleMainExit(MainExitException mee)
handleOutOfMemoryback to summary
private Main.Status handleOutOfMemory(OutOfMemoryError ex)

Print a nicer memory error since Rubyists aren't used to seeing this.

handleRaiseExceptionback to summary
protected static int handleRaiseException(final RaiseException ex)

This is only used from the main(String[]) path, in which case the err for this run should be System.err. In order to avoid the Ruby err being closed and unable to write, we use System.err unconditionally.

handleStackOverflowback to summary
private Main.Status handleStackOverflow(StackOverflowError ex)

Print a nicer stack size error since Rubyists aren't used to seeing this.

handleUnexpectedJumpback to summary
private static int handleUnexpectedJump(final JumpException ex)
handleUnsupportedClassVersionback to summary
private Main.Status handleUnsupportedClassVersion(UnsupportedClassVersionError ex)
internalRunback to summary
private Main.Status internalRun()
loadJRubyPropertiesback to summary
private static void loadJRubyProperties(File dotfile)
mainback to summary
public static void main(String[] args)

This is the command-line entry point for JRuby, and should ONLY be used by Java when starting up JRuby from a command-line. Use other mechanisms when embedding JRuby into another application.

Parameters
args:String[]

command-line args, provided by the JVM.

processDotfileback to summary
public static void processDotfile()
runback to summary
public Main.Status run(String[] args)
runback to summary
public Main.Status run()

Deprecated

Annotations
@Deprecated
org.jruby back to summary

public Class Main.Status

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private boolean
private int

Constructor Summary

AccessConstructor and Description
pack-priv
Status(int
The status value.
status
)

Creates a status object with the specified value and with explicit exit flag.

pack-priv
Status()

Creates a status object with 0 value and no explicit exit flag.

Method Summary

Modifier and TypeMethod and Description
public int
public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

isExitback to summary
private boolean isExit
statusback to summary
private int status

Constructor Detail

Statusback to summary
pack-priv Status(int status)

Creates a status object with the specified value and with explicit exit flag. An exit flag means that Kernel.exit() has been explicitly invoked during the run.

Parameters
status:int

The status value.

Statusback to summary
pack-priv Status()

Creates a status object with 0 value and no explicit exit flag.

Method Detail

getStatusback to summary
public int getStatus()
isExitback to summary
public boolean isExit()