1
1
/*
2
- * Copyright 2002-2013 the original author or authors.
2
+ * Copyright 2002-2014 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -80,7 +80,7 @@ public static Object createJRubyObject(String scriptSource, Class<?>[] interface
80
80
Ruby ruby = initializeRuntime ();
81
81
82
82
Node scriptRootNode = ruby .parseEval (scriptSource , "" , null , 0 );
83
- // keep using the deprecated runNormally variant for JRuby 1.1/1.2 compatibility...
83
+ // Keep using the deprecated runNormally variant for JRuby 1.1/1.2 compatibility...
84
84
IRubyObject rubyObject = ruby .runNormally (scriptRootNode , false );
85
85
86
86
if (rubyObject instanceof RubyNil ) {
@@ -118,10 +118,12 @@ private static String findClassName(Node rootNode) {
118
118
119
119
/**
120
120
* Find the first {@link ClassNode} under the supplied {@link Node}.
121
- * @return the found {@code ClassNode}, or {@code null}
122
- * if no {@link ClassNode} is found
121
+ * @return the corresponding {@code ClassNode}, or {@code null} if none found
123
122
*/
124
123
private static ClassNode findClassNode (Node node ) {
124
+ if (node == null ) {
125
+ return null ;
126
+ }
125
127
if (node instanceof ClassNode ) {
126
128
return (ClassNode ) node ;
127
129
}
@@ -230,8 +232,8 @@ private Object convertFromRubyArray(IRubyObject[] rubyArray, Class<?> returnType
230
232
/**
231
233
* Exception thrown in response to a JRuby {@link RaiseException}
232
234
* being thrown from a JRuby method invocation.
233
- * <p>Introduced because the {@code RaiseException} class does not
234
- * have useful {@link Object#toString()}, {@link Throwable#getMessage()},
235
+ * <p>Introduced because early versions of the {@code RaiseException} class did
236
+ * not have useful {@link Object#toString()}, {@link Throwable#getMessage()},
235
237
* and {@link Throwable#printStackTrace} implementations.
236
238
*/
237
239
@ SuppressWarnings ("serial" )
@@ -248,7 +250,7 @@ public JRubyExecutionException(RaiseException ex) {
248
250
249
251
private static String buildMessage (RaiseException ex ) {
250
252
RubyException rubyEx = ex .getException ();
251
- return (rubyEx != null && rubyEx .message != null ) ? rubyEx .message .toString () : "Unexpected JRuby error" ;
253
+ return (rubyEx != null && rubyEx .message != null ? rubyEx .message .toString () : "Unexpected JRuby error" ) ;
252
254
}
253
255
}
254
256
0 commit comments