Skip to content

Commit

Permalink
Showing 58 changed files with 1,403 additions and 482 deletions.
4 changes: 4 additions & 0 deletions core/pom.rb
Original file line number Diff line number Diff line change
@@ -75,6 +75,10 @@
jar 'org.jruby:joda-timezones:${tzdata.version}', :scope => '${tzdata.scope}'
jar 'joda-time:joda-time:${joda.time.version}'

# SLF4J only used within SLF4JLogger (JRuby logger impl) class
jar 'org.slf4j:slf4j-api:1.7.12', :scope => 'provided', :optional => true
jar 'org.slf4j:slf4j-simple:1.7.12', :scope => 'test'

plugin_management do
plugin( 'org.eclipse.m2e:lifecycle-mapping:1.0.0',
'lifecycleMappingMetadata' => {
13 changes: 13 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -263,6 +263,19 @@ DO NOT MODIFIY - GENERATED CODE
<artifactId>joda-time</artifactId>
<version>${joda.time.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.12</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<defaultGoal>package</defaultGoal>
15 changes: 9 additions & 6 deletions core/src/main/java/org/jruby/Main.java
Original file line number Diff line number Diff line change
@@ -76,7 +76,7 @@
* @author jpetersen
*/
public class Main {
private static final Logger LOG = LoggerFactory.getLogger("Main");
private static final Logger LOG = LoggerFactory.getLogger(Main.class);

public Main(RubyInstanceConfig config) {
this(config, false);
@@ -143,11 +143,14 @@ private static void loadJRubyProperties(File dotfile) {
for (Map.Entry entry : newProps.entrySet()) {
sysProps.put("jruby." + entry.getKey(), entry.getValue());
}
} catch (IOException ioe) {
LOG.debug("exception loading " + dotfile, ioe);
} catch (SecurityException se) {
LOG.debug("exception loading " + dotfile, se);
} finally {
}
catch (IOException ioe) {
if (LOG.isDebugEnabled()) LOG.debug("exception loading " + dotfile, ioe);
}
catch (SecurityException se) {
if (LOG.isDebugEnabled()) LOG.debug("exception loading " + dotfile, se);
}
finally {
if (fis != null) try {fis.close();} catch (Exception e) {}
}
}
46 changes: 26 additions & 20 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -224,7 +224,10 @@ public final class Ruby implements Constantizable {
/**
* The logger used to log relevant bits.
*/
private static final Logger LOG = LoggerFactory.getLogger("Ruby");
private static final Logger LOG = LoggerFactory.getLogger(Ruby.class);
static { // enable DEBUG output
if (RubyInstanceConfig.JIT_LOADING_DEBUG) LOG.setDebugEnable(true);
}

/**
* Create and initialize a new JRuby runtime. The properties of the
@@ -655,13 +658,15 @@ public IRubyObject runWithGetsLoop(RootNode scriptNode, boolean printing, boolea
try {
script = tryCompile(scriptNode);
if (Options.JIT_LOGGING.load()) {
LOG.info("Successfully compiled: " + scriptNode.getFile());
LOG.info("Successfully compiled: {}", scriptNode.getFile());
}
} catch (Throwable e) {
if (Options.JIT_LOGGING.load()) {
LOG.error("Failed to compile: " + scriptNode.getFile());
if (Options.JIT_LOGGING_VERBOSE.load()) {
LOG.error(e);
LOG.error("Failed to compile: " + scriptNode.getFile(), e);
}
else {
LOG.error("Failed to compile: " + scriptNode.getFile());
}
}
}
@@ -805,9 +810,12 @@ private ScriptAndCode tryCompile(RootNode root, ClassDefiningClassLoader classLo
return Compiler.getInstance().execute(this, root, classLoader);
} catch (NotCompilableException e) {
if (Options.JIT_LOGGING.load()) {
LOG.error("failed to compile target script " + root.getFile() + ": " + e.getLocalizedMessage());

if (Options.JIT_LOGGING_VERBOSE.load()) LOG.error(e);
if (Options.JIT_LOGGING_VERBOSE.load()) {
LOG.error("failed to compile target script " + root.getFile() + ": ", e);
}
else {
LOG.error("failed to compile target script " + root.getFile() + ": " + e.getLocalizedMessage());
}
}
return null;
}
@@ -3016,22 +3024,22 @@ public void compileAndLoadFile(String filename, InputStream in, boolean wrap) {
Class contents;
try {
contents = getJRubyClassLoader().loadClass(className);
if (RubyInstanceConfig.JIT_LOADING_DEBUG) {
LOG.info("found jitted code for " + filename + " at class: " + className);
if (LOG.isDebugEnabled()) { // RubyInstanceConfig.JIT_LOADING_DEBUG
LOG.debug("found jitted code for " + filename + " at class: " + className);
}
script = (Script) contents.newInstance();
readStream = new ByteArrayInputStream(buffer);
} catch (ClassNotFoundException cnfe) {
if (RubyInstanceConfig.JIT_LOADING_DEBUG) {
LOG.info("no jitted code in classloader for file " + filename + " at class: " + className);
if (LOG.isDebugEnabled()) { // RubyInstanceConfig.JIT_LOADING_DEBUG
LOG.debug("no jitted code in classloader for file " + filename + " at class: " + className);
}
} catch (InstantiationException ie) {
if (RubyInstanceConfig.JIT_LOADING_DEBUG) {
LOG.info("jitted code could not be instantiated for file " + filename + " at class: " + className);
} catch (InstantiationException ex) {
if (LOG.isDebugEnabled()) { // RubyInstanceConfig.JIT_LOADING_DEBUG
LOG.debug("jitted code could not be instantiated for file " + filename + " at class: " + className + ' ' + ex);
}
} catch (IllegalAccessException iae) {
if (RubyInstanceConfig.JIT_LOADING_DEBUG) {
LOG.info("jitted code could not be instantiated for file " + filename + " at class: " + className);
} catch (IllegalAccessException ex) {
if (LOG.isDebugEnabled()) { // RubyInstanceConfig.JIT_LOADING_DEBUG
LOG.debug("jitted code could not be instantiated for file " + filename + " at class: " + className + ' ' + ex);
}
}
} catch (IOException ioe) {
@@ -4018,9 +4026,7 @@ public RaiseException newSystemStackError(String message) {
}

public RaiseException newSystemStackError(String message, StackOverflowError soe) {
if (getDebug().isTrue()) {
LOG.debug(soe.getMessage(), soe);
}
if ( isDebug() ) LOG.debug(soe);
return newRaiseException(getSystemStackError(), message);
}

4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
@@ -110,9 +110,9 @@
*/
public class RubyBasicObject implements Cloneable, IRubyObject, Serializable, Comparable<IRubyObject>, CoreObjectType, InstanceVariables, InternalVariables {

private static final Logger LOG = LoggerFactory.getLogger("RubyBasicObject");
//private static final Logger LOG = LoggerFactory.getLogger(RubyBasicObject.class);

private static final boolean DEBUG = false;
//private static final boolean DEBUG = false;

/** The class of this object */
protected transient RubyClass metaClass;
7 changes: 3 additions & 4 deletions core/src/main/java/org/jruby/RubyClass.java
Original file line number Diff line number Diff line change
@@ -100,7 +100,7 @@
@JRubyClass(name="Class", parent="Module")
public class RubyClass extends RubyModule {

private static final Logger LOG = LoggerFactory.getLogger("RubyClass");
private static final Logger LOG = LoggerFactory.getLogger(RubyClass.class);

public static void createClassClass(Ruby runtime, RubyClass classClass) {
classClass.setClassIndex(ClassIndex.CLASS);
@@ -1634,9 +1634,8 @@ private boolean isVarArgsSignature(final String method, final Class[] methodSign

private void logReifyException(final Throwable failure, final boolean error) {
if (RubyInstanceConfig.REIFY_LOG_ERRORS) {
final String msg = "failed to reify class " + getName() + " due to: ";
if ( error ) LOG.error(msg, failure);
else LOG.info(msg, failure);
if ( error ) LOG.error("failed to reify class " + getName() + " due to: ", failure);
else LOG.info("failed to reify class " + getName() + " due to: ", failure);
}
}

17 changes: 8 additions & 9 deletions core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
@@ -128,9 +128,9 @@
@JRubyClass(name="Module")
public class RubyModule extends RubyObject {

private static final Logger LOG = LoggerFactory.getLogger("RubyModule");
private static final Logger LOG = LoggerFactory.getLogger(RubyModule.class);
// static { LOG.setDebugEnable(true); } // enable DEBUG output

private static final boolean DEBUG = false;
protected static final String ERR_INSECURE_SET_CONSTANT = "Insecure: can't modify constant";

public static final ObjectAllocator MODULE_ALLOCATOR = new ObjectAllocator() {
@@ -1016,23 +1016,22 @@ public final Map<String, List<JavaMethodDescriptor>> getStaticAnnotatedMethods()
public static TypePopulator loadPopulatorFor(Class<?> type) {
if (Options.DEBUG_FULLTRACE.load() || Options.REFLECTED_HANDLES.load()) {
// we want non-generated invokers or need full traces, use default (slow) populator
if (DEBUG) LOG.info("trace mode, using default populator");
LOG.debug("trace mode, using default populator");
} else {
try {
String qualifiedName = "org.jruby.gen." + type.getCanonicalName().replace('.', '$');
String fullName = qualifiedName + AnnotationBinder.POPULATOR_SUFFIX;
String fullPath = fullName.replace('.', '/') + ".class";

if (DEBUG) LOG.info("looking for " + fullName);
if (LOG.isDebugEnabled()) LOG.debug("looking for populator " + fullName);

if (Ruby.getClassLoader().getResource(fullPath) == null) {
if (DEBUG) LOG.info("Could not find it, using default populator");
LOG.debug("could not find it, using default populator");
} else {
Class populatorClass = Class.forName(qualifiedName + AnnotationBinder.POPULATOR_SUFFIX);
return (TypePopulator) populatorClass.newInstance();
}
} catch (Throwable t) {
if (DEBUG) LOG.info("Could not find it, using default populator");
} catch (Throwable ex) {
if (LOG.isDebugEnabled()) LOG.debug("could not find populator, using default (" + ex + ')');
}
}

@@ -1439,7 +1438,7 @@ protected DynamicMethod searchMethodCommon(String name) {
}

public void invalidateCacheDescendants() {
if (DEBUG) LOG.debug("invalidating descendants: {}", baseName);
LOG.debug("{} invalidating descendants", baseName);

if (includingHierarchies.isEmpty()) {
// it's only us; just invalidate directly
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/RubyThread.java
Original file line number Diff line number Diff line change
@@ -103,7 +103,8 @@
@JRubyClass(name="Thread")
public class RubyThread extends RubyObject implements ExecutionContext {

private static final Logger LOG = LoggerFactory.getLogger("RubyThread");
private static final Logger LOG = LoggerFactory.getLogger(RubyThread.class);
// static { LOG.setDebugEnable(true); }

/** The thread-like think that is actually executing */
private volatile ThreadLike threadImpl;
@@ -151,7 +152,6 @@ public class RubyThread extends RubyObject implements ExecutionContext {
/** Thread-local tuple used for sleeping (semaphore, millis, nanos) */
private final SleepTask2 sleepTask = new SleepTask2();

private static final boolean DEBUG = false;
public static final int RUBY_MIN_THREAD_PRIORITY = -3;
public static final int RUBY_MAX_THREAD_PRIORITY = 3;

@@ -1516,7 +1516,7 @@ public void dieFromFinalizer() {
}

private static void debug(RubyThread thread, String message) {
if (DEBUG) LOG.debug(Thread.currentThread() + "(" + thread.status + "): " + message);
if (LOG.isDebugEnabled()) LOG.debug( "{} ({}): {}", Thread.currentThread(), thread.status, message );
}

@JRubyMethod
28 changes: 13 additions & 15 deletions core/src/main/java/org/jruby/anno/InvokerGenerator.java
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
* rights and limitations under the License.
*
* Copyright (C) 2008-2012 Charles Oliver Nutter <headius@headius.com>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
@@ -39,25 +39,22 @@
import org.jruby.RubyModule.MethodClumper;
import org.jruby.internal.runtime.methods.DumpingInvocationMethodFactory;
import org.jruby.util.ClassDefiningJRubyClassLoader;
import org.jruby.util.log.Logger;
import org.jruby.util.log.LoggerFactory;

public class InvokerGenerator {

private static final Logger LOG = LoggerFactory.getLogger("InvokerGenerator");
private static final boolean DEBUG = false;

public static final boolean DEBUG = false;

public static void main(String[] args) throws Exception {
FileReader fr = null;
final FileReader fileReader;
try {
fr = new FileReader(args[0]);
} catch(FileNotFoundException e) {
fileReader = new FileReader(args[0]);
}
catch (FileNotFoundException e) {
System.err.println(args[0] + " - not found. skip generator." );
return;
}
BufferedReader br = new BufferedReader(fr);
BufferedReader br = new BufferedReader(fileReader);

List<String> classNames = new ArrayList<String>();
try {
String line;
@@ -72,9 +69,9 @@ public static void main(String[] args) throws Exception {

for (String name : classNames) {
MethodClumper clumper = new MethodClumper();

try {
if (DEBUG) LOG.debug("generating for class {}", name);
if (DEBUG) System.err.println("generating for class " + name);
Class cls = Class.forName(name, false, InvokerGenerator.class.getClassLoader());

clumper.clump(cls);
@@ -86,8 +83,9 @@ public static void main(String[] args) throws Exception {
for (Map.Entry<String, List<JavaMethodDescriptor>> entry : clumper.getAnnotatedMethods().entrySet()) {
dumper.getAnnotatedMethodClass(entry.getValue());
}
} catch (Exception e) {
e.printStackTrace();
}
catch (Exception e) {
e.printStackTrace(System.err);
throw e;
}
}
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/compiler/JITCompiler.java
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@
import java.util.concurrent.atomic.AtomicLong;

public class JITCompiler implements JITCompilerMBean {
private static final Logger LOG = LoggerFactory.getLogger("JITCompiler");
private static final Logger LOG = LoggerFactory.getLogger(JITCompiler.class);

public static final String RUBY_JIT_PREFIX = "rubyjit";

Loading

0 comments on commit d477355

Please sign in to comment.