Skip to content

Commit

Permalink
Showing 14 changed files with 79 additions and 42 deletions.
5 changes: 3 additions & 2 deletions truffle/src/main/java/org/jruby/truffle/JRubyTruffleImpl.java
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
import org.jruby.Ruby;
import org.jruby.truffle.interop.JRubyContextWrapper;
import org.jruby.truffle.language.control.ExitException;
import org.jruby.truffle.language.control.JavaException;
import org.jruby.truffle.platform.graal.Graal;
import org.jruby.util.cli.Options;

@@ -39,7 +40,7 @@ public JRubyTruffleImpl(Ruby runtime) {
try {
context = (RubyContext) engine.eval(loadSource("Truffle::Boot.context", "context")).get();
} catch (IOException e) {
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -61,7 +62,7 @@ public Object execute(org.jruby.ast.RootNode rootNode) {
throw new org.jruby.exceptions.MainExitException(exit.getCode());
}

throw new RuntimeException(e);
throw new JavaException(e);
}
}

7 changes: 4 additions & 3 deletions truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
Original file line number Diff line number Diff line change
@@ -103,6 +103,7 @@
import org.jruby.truffle.language.TruffleBootNodesFactory;
import org.jruby.truffle.language.TruffleSafeNodesFactory;
import org.jruby.truffle.language.backtrace.BacktraceFormatter;
import org.jruby.truffle.language.control.JavaException;
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.control.TruffleFatalException;
import org.jruby.truffle.language.globals.GlobalVariableStorage;
@@ -282,7 +283,7 @@ public String getCoreLoadPath() {
try {
return new File(path).getCanonicalPath();
} catch (IOException e) {
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -1033,7 +1034,7 @@ public void loadRubyCore() {
deferredCall.callWithoutCallNode();
}
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
throw new JavaException(e);
}

Main.printTruffleTimeMetric("after-load-core");
@@ -1068,7 +1069,7 @@ public void initializePostBoot() {
deferredCall.callWithoutCallNode();
}
} catch (IOException e) {
throw new RuntimeException(e);
throw new JavaException(e);
}

Main.printTruffleTimeMetric("after-post-boot");
Original file line number Diff line number Diff line change
@@ -91,6 +91,7 @@
import org.jruby.truffle.language.arguments.RubyArguments;
import org.jruby.truffle.language.backtrace.Activation;
import org.jruby.truffle.language.backtrace.Backtrace;
import org.jruby.truffle.language.control.JavaException;
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.language.dispatch.DispatchHeadNodeFactory;
@@ -179,7 +180,7 @@ private DynamicObject spawnAndCaptureOutput(DynamicObject command, final Dynamic
// We need to run via bash to get the variable and other expansion we expect
process = Runtime.getRuntime().exec(new String[]{ "bash", "-c", command.toString() }, envp.toArray(new String[envp.size()]));
} catch (IOException e) {
throw new RuntimeException(e);
throw new JavaException(e);
}

final InputStream stdout = process.getInputStream();
@@ -196,7 +197,7 @@ private DynamicObject spawnAndCaptureOutput(DynamicObject command, final Dynamic
resultBuilder.append((char) c);
}
} catch (IOException e) {
throw new RuntimeException(e);
throw new JavaException(e);
}

// TODO (nirvdrum 10-Mar-15) This should be using the default external encoding, rather than hard-coded to UTF-8.
@@ -737,7 +738,7 @@ private void exec(RubyContext context, DynamicObject envAsHash, String[] command
process = builder.start();
} catch (IOException e) {
// TODO(cs): proper Ruby exception
throw new RuntimeException(e);
throw new JavaException(e);
}

int exitCode = context.getThreadManager().runUntilResult(this, new BlockingAction<Integer>() {
@@ -844,7 +845,7 @@ private static String gets(BufferedReader reader) throws InterruptedException {
try {
return reader.readLine() + "\n";
} catch (IOException e) {
throw new RuntimeException(e);
throw new JavaException(e);
}
}

31 changes: 16 additions & 15 deletions truffle/src/main/java/org/jruby/truffle/interop/InteropNodes.java
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@
import org.jruby.truffle.core.rope.Rope;
import org.jruby.truffle.core.string.StringCachingGuards;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.control.JavaException;
import org.jruby.util.ByteList;
import java.io.IOException;

@@ -82,7 +83,7 @@ public Object executeForeignCached(
return ForeignAccess.sendExecute(executeNode, frame, receiver, args);
} catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) {
exceptionProfile.enter();
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -98,7 +99,7 @@ public Object executeForeignUncached(
try {
return ForeignAccess.sendExecute(executeNode, frame, receiver, args);
} catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) {
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -143,7 +144,7 @@ public Object invokeCached(
| UnsupportedMessageException
| UnknownIdentifierException e) {
exceptionProfile.enter();
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -166,7 +167,7 @@ public Object invokeUncached(
| ArityException
| UnsupportedMessageException
| UnknownIdentifierException e) {
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -215,7 +216,7 @@ public Object size(
return ForeignAccess.sendGetSize(getSizeNode, frame, receiver);
} catch (UnsupportedMessageException e) {
exceptionProfile.enter();
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -309,7 +310,7 @@ public Object unbox(
return ForeignAccess.sendUnbox(unboxNode, frame, receiver);
} catch (UnsupportedMessageException e) {
exceptionProfile.enter();
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -361,7 +362,7 @@ public Object read(
return ForeignAccess.sendRead(readNode, frame, receiver, identifier);
} catch (UnknownIdentifierException | UnsupportedMessageException e) {
exceptionProfile.enter();
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -378,7 +379,7 @@ public Object read(
return ForeignAccess.sendRead(readNode, frame, receiver, identifierString);
} catch (UnknownIdentifierException | UnsupportedMessageException e) {
exceptionProfile.enter();
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -401,7 +402,7 @@ public Object readCached(
return ForeignAccess.sendRead(readNode, frame, receiver, identifierString);
} catch (UnknownIdentifierException | UnsupportedMessageException e) {
exceptionProfile.enter();
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -419,7 +420,7 @@ public Object readUncached(
return ForeignAccess.sendRead(readNode, frame, receiver, objectToString(identifier));
} catch (UnknownIdentifierException | UnsupportedMessageException e) {
exceptionProfile.enter();
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -454,7 +455,7 @@ public Object write(
return ForeignAccess.sendWrite(writeNode, frame, receiver, identifier, value);
} catch (UnknownIdentifierException | UnsupportedTypeException | UnsupportedMessageException e) {
exceptionProfile.enter();
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -472,7 +473,7 @@ public Object write(
return ForeignAccess.sendWrite(writeNode, frame, receiver, identifierString, value);
} catch (UnknownIdentifierException | UnsupportedTypeException | UnsupportedMessageException e) {
exceptionProfile.enter();
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -496,7 +497,7 @@ public Object writeCached(
return ForeignAccess.sendWrite(writeNode, frame, receiver, identifierString, value);
} catch (UnknownIdentifierException | UnsupportedTypeException | UnsupportedMessageException e) {
exceptionProfile.enter();
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -515,7 +516,7 @@ public Object writeUncached(
return ForeignAccess.sendWrite(writeNode, frame, receiver, objectToString(identifier), value);
} catch (UnknownIdentifierException | UnsupportedTypeException | UnsupportedMessageException e) {
exceptionProfile.enter();
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -603,7 +604,7 @@ protected CallTarget parse(DynamicObject mimeType, DynamicObject source) {
return getContext().getEnv().parse(sourceObject);
} catch (IOException e) {
CompilerDirectives.transferToInterpreterAndInvalidate();
throw new RuntimeException(e);
throw new JavaException(e);
}
}

Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.control.JavaException;

@NodeChildren({
@NodeChild("receiver"),
@@ -155,7 +156,7 @@ public Object executeCall(VirtualFrame frame, TruffleObject receiver, Object[] a
return ForeignAccess.sendRead(node, frame, receiver, args[0]);
} catch (UnknownIdentifierException | UnsupportedMessageException e) {
exceptionProfile();
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -177,7 +178,7 @@ public Object executeCall(VirtualFrame frame, TruffleObject receiver, Object[] a
return ForeignAccess.sendWrite(node, frame, receiver, args[0], args[1]);
} catch (UnknownIdentifierException | UnsupportedMessageException | UnsupportedTypeException e) {
exceptionProfile();
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -202,7 +203,7 @@ public Object executeCall(VirtualFrame frame, TruffleObject receiver, Object[] a
return ForeignAccess.sendRead(node, frame, receiver, name);
} catch (UnknownIdentifierException | UnsupportedMessageException e) {
exceptionProfile();
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -227,7 +228,7 @@ public Object executeCall(VirtualFrame frame, TruffleObject receiver, Object[] a
return ForeignAccess.sendWrite(node, frame, receiver, name, args[0]);
} catch (UnknownIdentifierException | UnsupportedMessageException | UnsupportedTypeException e) {
exceptionProfile();
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -252,7 +253,7 @@ public Object executeCall(VirtualFrame frame, TruffleObject receiver, Object[] a
return ForeignAccess.sendExecute(node, frame, receiver, args);
} catch (UnsupportedTypeException | ArityException | UnsupportedMessageException e) {
exceptionProfile();
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -296,7 +297,7 @@ public Object executeCall(VirtualFrame frame, TruffleObject receiver, Object[] a
return ForeignAccess.sendInvoke(node, frame, receiver, name, args);
} catch (UnsupportedTypeException | ArityException | UnsupportedMessageException | UnknownIdentifierException e) {
exceptionProfile();
throw new RuntimeException(e);
throw new JavaException(e);
}
}

Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@
import org.jruby.truffle.builtins.CoreMethodNode;
import org.jruby.truffle.core.CoreLibrary;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.control.JavaException;
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.loader.CodeLoader;
import org.jruby.truffle.language.loader.SourceLoader;
@@ -102,7 +103,7 @@ public Object runJRubyRootNode(VirtualFrame frame, @Cached("create()") IndirectC
try {
source = getContext().getSourceCache().getSource(inputFile);
} catch (IOException e) {
throw new RuntimeException(e);
throw new JavaException(e);
}

final RubyRootNode rootNode = getContext().getCodeLoader().parse(
@@ -177,7 +178,7 @@ public boolean requireRelative(VirtualFrame frame, DynamicObject feature, @Cache
final CodeLoader.DeferredCall deferredCall = codeLoader.prepareExecute(ParserContext.TOP_LEVEL, DeclarationContext.TOP_LEVEL, rootNode, null, coreLibrary.getMainObject());
deferredCall.callWithoutCallNode();
} catch (IOException e) {
throw new RuntimeException(e);
throw new JavaException(e);
}

return true;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.language.control;

public class JavaException extends RuntimeException {

public JavaException(Throwable cause) {
super(cause);
}

@Override
public final Throwable fillInStackTrace() {
return null;
}

}
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.RubyLanguage;
import org.jruby.truffle.core.array.ArrayOperations;
import org.jruby.truffle.language.control.JavaException;

public class FeatureLoader {

@@ -132,7 +133,7 @@ private CallTarget getCExtLibRuby() {
try {
return parseSource(context.getSourceLoader().load(path));
} catch (IOException e) {
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -141,7 +142,7 @@ public CallTarget parseSource(Source source) {
try {
return context.getEnv().parse(source);
} catch (IOException e) {
throw new RuntimeException(e);
throw new JavaException(e);
}
}

Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.RubyNode;
import org.jruby.truffle.language.RubyRootNode;
import org.jruby.truffle.language.control.JavaException;
import org.jruby.truffle.language.control.RaiseException;
import org.jruby.truffle.language.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.language.methods.DeclarationContext;
@@ -142,7 +143,7 @@ protected boolean require(VirtualFrame frame, String feature,
ForeignAccess.sendExecute(executeNode, frame, initFunction);
} catch (InteropException e) {
CompilerDirectives.transferToInterpreterAndInvalidate();
throw new RuntimeException(e);
throw new JavaException(e);
}
break;
}
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@
*/
package org.jruby.truffle.platform.openjdk;

import org.jruby.truffle.language.control.JavaException;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.Field;
@@ -20,7 +22,7 @@ public static MethodHandle getPrivateGetter(Class<?> klass, String fieldName) {
try {
return MethodHandles.lookup().unreflectGetter(field);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -30,7 +32,7 @@ private static Field getPrivateField(final Class<?> klass, final String fieldNam
field.setAccessible(true);
return field;
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
throw new JavaException(e);
}
}

Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@

import org.jruby.truffle.core.queue.ArrayBlockingQueueLocksConditions;
import org.jruby.truffle.core.queue.DelegatingBlockingQueue;
import org.jruby.truffle.language.control.JavaException;

import java.lang.invoke.MethodHandle;
import java.util.concurrent.ArrayBlockingQueue;
@@ -43,7 +44,7 @@ public OpenJDKArrayBlockingQueueLocksConditions(int capacity) {
notEmptyCondition = (Condition) NOT_EMPTY_CONDITION_FIELD_GETTER.invokeExact(queue);
notFullCondition = (Condition) NOT_FULL_CONDITION_FIELD_GETTER.invokeExact(queue);
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
throw new JavaException(throwable);
}
}

Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@

import org.jruby.truffle.core.queue.DelegatingBlockingQueue;
import org.jruby.truffle.core.queue.LinkedBlockingQueueLocksConditions;
import org.jruby.truffle.language.control.JavaException;

import java.lang.invoke.MethodHandle;
import java.util.concurrent.LinkedBlockingQueue;
@@ -38,7 +39,7 @@ public OpenJDKLinkedBlockingQueueLocksConditions() {
lock = (ReentrantLock) TAKE_LOCK_FIELD_GETTER.invokeExact(queue);
notEmptyCondition = (Condition) NOT_EMPTY_CONDITION_FIELD_GETTER.invokeExact(queue);
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
throw new JavaException(throwable);
}
}

Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
import org.jruby.truffle.core.rope.Rope;
import org.jruby.truffle.core.rope.RopeOperations;
import org.jruby.truffle.core.string.StringOperations;
import org.jruby.truffle.language.control.JavaException;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -36,7 +37,7 @@ private static MessageDigest getMessageDigestInstance(String name) {
try {
return MessageDigest.getInstance(name);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
throw new JavaException(e);
}
}

@@ -147,7 +148,7 @@ private static byte[] cloneAndDigest(MessageDigest digest) {
try {
clonedDigest = (MessageDigest) digest.clone();
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
throw new JavaException(e);
}

return clonedDigest.digest();
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@
import com.oracle.truffle.api.vm.PolyglotEngine.Value;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.RubyLanguage;
import org.jruby.truffle.language.control.JavaException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -101,7 +102,7 @@ public void run() {
debugger.setLineBreakpoint(0, returnOne, false);
executionEvent.prepareContinue();
} catch (IOException e) {
throw new RuntimeException(e);
throw new JavaException(e);
}
}

0 comments on commit bd52959

Please sign in to comment.