Skip to content

Commit

Permalink
Showing 25 changed files with 426 additions and 297 deletions.
54 changes: 26 additions & 28 deletions core/pom.rb
Original file line number Diff line number Diff line change
@@ -287,43 +287,41 @@
end
end

unless ENV['JRUBY_NO_ANT']

jruby_bin_config = [ 'run', { :id => 'copy',
'tasks' => {
'exec' => {
'@executable' => '/bin/sh',
'@osfamily' => 'unix',
'arg' => {
'@line' => '-c \'cp "${jruby.basedir}/bin/jruby.bash" "${jruby.basedir}/bin/jruby"\''
}
},
'chmod' => {
'@file' => '${jruby.basedir}/bin/jruby',
'@perm' => '755'
}
} } ]
copy_goal = [:exec, :executable => '/bin/sh', :arguments => ['-c', 'cp ${jruby.basedir}/bin/jruby.bash ${jruby.basedir}/bin/jruby']]

profile :clean do
activation do
# hack to get the os triggeer into the model
os = org.apache.maven.model.ActivationOS.new
os.family = 'unix'
@current.os = os
end

phase :clean do
plugin :antrun do
execute_goals( *jruby_bin_config )
plugin 'org.codehaus.mojo:exec-maven-plugin' do
execute_goals( *copy_goal )
end
end
end

profile 'jruby.bash' do
profile 'jruby.bash' do

activation do
file( :missing => '../bin/jruby' )
end
activation do
file( :missing => '../bin/jruby' )
end
activation do
# hack to get the os triggeer into the model
os = org.apache.maven.model.ActivationOS.new
os.family = 'unix'
@current.os = os
end

phase :initialize do
plugin :antrun do
execute_goals( *jruby_bin_config )
end
phase :initialize do
plugin 'org.codehaus.mojo:exec-maven-plugin' do
execute_goals *copy_goal
end

end

end

jni_config = [ 'unpack', { :id => 'unzip native',
73 changes: 42 additions & 31 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -625,26 +625,6 @@ DO NOT MODIFIY - GENERATED CODE
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>clean</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<exec executable="/bin/sh" osfamily="unix">
<arg line="-c 'cp &quot;${jruby.basedir}/bin/jruby.bash&quot; &quot;${jruby.basedir}/bin/jruby&quot;'" />
</exec>
<chmod file="${jruby.basedir}/bin/jruby" perm="755" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
@@ -938,30 +918,61 @@ DO NOT MODIFIY - GENERATED CODE
</plugins>
</build>
</profile>
<profile>
<id>clean</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<phase>clean</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>/bin/sh</executable>
<arguments>
<argument>-c</argument>
<argument>cp ${jruby.basedir}/bin/jruby.bash ${jruby.basedir}/bin/jruby</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>jruby.bash</id>
<activation>
<file>
<missing>../bin/jruby</missing>
</file>
<os>
<family>unix</family>
</os>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>run</goal>
<goal>exec</goal>
</goals>
<configuration>
<tasks>
<exec executable="/bin/sh" osfamily="unix">
<arg line="-c 'cp &quot;${jruby.basedir}/bin/jruby.bash&quot; &quot;${jruby.basedir}/bin/jruby&quot;'" />
</exec>
<chmod file="${jruby.basedir}/bin/jruby" perm="755" />
</tasks>
<executable>/bin/sh</executable>
<arguments>
<argument>-c</argument>
<argument>cp ${jruby.basedir}/bin/jruby.bash ${jruby.basedir}/bin/jruby</argument>
</arguments>
</configuration>
</execution>
</executions>
131 changes: 104 additions & 27 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -3956,45 +3956,56 @@ public RaiseException newIllegalSequence(String message) {
return newRaiseException(getClass("Iconv").getClass("IllegalSequence"), message);
}

public RaiseException newNoMethodError(String message, String name, IRubyObject args) {
return new RaiseException(new RubyNoMethodError(this, getNoMethodError(), message, name, args), true);
}

public RaiseException newNameError(String message, String name) {
return newNameError(message, name, null);
}

@Deprecated
public RaiseException newNameErrorObject(String message, IRubyObject name) {
RubyException error = new RubyNameError(this, getNameError(), message, name);

return new RaiseException(error, false);
}

public RaiseException newNameError(String message, String name, Throwable origException) {
return newNameError(message, name, origException, false);
}

/**
* Construct a NameError that formats its message with an sprintf format string.
*
* The arguments given to sprintf are as follows:
*
* 0: the name that failed
* 1: the receiver object that failed
* 2: a ":" character for non-singleton recv, blank otherwise
* 3: the name of the a non-singleton recv's class, blank if recv is a singleton
*
* Passing a string with no format characters will warn in verbose mode and error in debug mode.
*
* See jruby/jruby#3934.
*
* @param message an sprintf format string for the message
* @param recv the receiver object
* @param name the name that failed
* @return a new NameError
*/
public RaiseException newNameError(String message, IRubyObject recv, IRubyObject name) {
IRubyObject msg = new RubyNameError.RubyNameErrorMessage(this, message, recv, name);
RubyException err = RubyNameError.newNameError(getNameError(), msg, name);

return new RaiseException(err);
}

/**
* Construct a NameError that formats its message with an sprintf format string.
*
* This version just accepts a java.lang.String for the name.
*
* @see Ruby#newNameError(String, IRubyObject, IRubyObject)
*/
public RaiseException newNameError(String message, IRubyObject recv, String name) {
RubySymbol nameSym = newSymbol(name);
return newNameError(message, recv, nameSym);
}

public RaiseException newNoMethodError(String message, IRubyObject recv, String name, RubyArray args) {
RubySymbol nameStr = newSymbol(name);
IRubyObject msg = new RubyNameError.RubyNameErrorMessage(this, message, recv, nameStr);
RubyException err = RubyNoMethodError.newNoMethodError(getNoMethodError(), msg, nameStr, args);

return new RaiseException(err);
}

/**
* Construct a NameError with the given pre-formatted message, name, and optional original exception.
*
* If the original exception is given, and either we are in verbose mode with printWhenVerbose set to true
* or we are in debug mode.
*
* @param message the pre-formatted message for the NameError
* @param name the name that failed
* @param origException the original exception, or null
* @param printWhenVerbose whether to log this exception when verbose mode is enabled
* @return a new NameError
*/
public RaiseException newNameError(String message, String name, Throwable origException, boolean printWhenVerbose) {
if (origException != null) {
if (printWhenVerbose && isVerbose()) {
@@ -4007,6 +4018,65 @@ public RaiseException newNameError(String message, String name, Throwable origEx
return new RaiseException(new RubyNameError(this, getNameError(), message, name), false);
}

/**
* Construct a NameError with a pre-formatted message and name.
*
* This is the same as calling {@link #newNameError(String, String, Throwable)} with a null
* originating exception.
*
* @param message the pre-formatted message for the error
* @param name the name that failed
* @return a new NameError
*/
public RaiseException newNameError(String message, String name) {
return newNameError(message, name, null);
}

/**
* Construct a NameError with an optional originating exception and a pre-formatted message.
*
* This is the same as calling {@link #newNameError(String, String, Throwable, boolean)} with a null
* originating exception and false for verbose-mode logging.
*
* @param message a formatted string message for the error
* @param name the name that failed
* @param origException the original exception, or null if none
* @return a new NameError
*/
public RaiseException newNameError(String message, String name, Throwable origException) {
return newNameError(message, name, origException, false);
}

/**
* Construct a NoMethodError that formats its message with an sprintf format string.
*
* This works like {@link #newNameError(String, IRubyObject, IRubyObject)} but accepts
* a java.lang.String for name and a RubyArray of the original call arguments.
*
* @see Ruby#newNameError(String, IRubyObject, IRubyObject)
*
* @return a new NoMethodError
*/
public RaiseException newNoMethodError(String message, IRubyObject recv, String name, RubyArray args) {
RubySymbol nameStr = newSymbol(name);
IRubyObject msg = new RubyNameError.RubyNameErrorMessage(this, message, recv, nameStr);
RubyException err = RubyNoMethodError.newNoMethodError(getNoMethodError(), msg, nameStr, args);

return new RaiseException(err);
}

/**
* Construct a NoMethodError with a pre-formatted message.
*
* @param message the pre-formatted message
* @param name the name that failed
* @param args the original arguments to the call that failed
* @return a new NoMethodError
*/
public RaiseException newNoMethodError(String message, String name, IRubyObject args) {
return new RaiseException(new RubyNoMethodError(this, getNoMethodError(), message, name, args), true);
}

public RaiseException newLocalJumpError(RubyLocalJumpError.Reason reason, IRubyObject exitValue, String message) {
return new RaiseException(new RubyLocalJumpError(this, getLocalJumpError(), message, reason, exitValue), true);
}
@@ -5031,6 +5101,13 @@ public void checkSafeString(IRubyObject object) {
public void secure(int level) {
}

@Deprecated
public RaiseException newNameErrorObject(String message, IRubyObject name) {
RubyException error = new RubyNameError(this, getNameError(), message, name);

return new RaiseException(error, false);
}

// Parser stats methods
private void addLoadParseToStats() {
if (parserStats != null) parserStats.addLoadParse();
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
@@ -2792,7 +2792,7 @@ public IRubyObject remove_instance_variable(ThreadContext context, IRubyObject n
if ((value = (IRubyObject)variableTableRemove(validateInstanceVariable(name, name.asJavaString()))) != null) {
return value;
}
throw context.runtime.newNameError("instance variable " + name.asJavaString() + " not defined", this, name);
throw context.runtime.newNameError("instance variable %1$s not defined", this, name);
}

/** rb_obj_instance_variables
@@ -2885,13 +2885,13 @@ protected static int nonFixnumHashCode(IRubyObject hashValue) {
protected String validateInstanceVariable(String name) {
if (IdUtil.isValidInstanceVariableName(name)) return name;

throw getRuntime().newNameError("`" + name + "' is not allowable as an instance variable name", this, name);
throw getRuntime().newNameError("`%1$s' is not allowable as an instance variable name", this, name);
}

protected String validateInstanceVariable(IRubyObject nameObj, String name) {
if (IdUtil.isValidInstanceVariableName(name)) return name;

throw getRuntime().newNameError("`" + name + "' is not allowable as an instance variable name", this, nameObj);
throw getRuntime().newNameError("`%1$s' is not allowable as an instance variable name", this, nameObj);
}

/**
Loading

0 comments on commit 258a83c

Please sign in to comment.