Ouch. Oh well, here's a mondo patch with everything except for my
completely new files:
But I'm starting to have a nagging worry that this may be something with
that \n\r vs \n -trouble, or something else Win32-related... =/
/O
At 18:08 2006-06-16, you wrote:
I tried without the critical patch and still had it...
all patches: error
just my version of your stuff: error (confirmed with tom's version of your
stuff too)
HEAD: ok
Perhaps something was missed in your patches, or we applied something
wrong? Could you send a complete patch for all your recent changes, and
we'll see if it works better?
On 6/16/06, Ola Bini <<mailto:[EMAIL PROTECTED]>[EMAIL PROTECTED]> wrote:
Hi,
I've attached the NIO patch and everything still seems to work. Maybe I
should try with your critical-patch too?
/O
--
Charles Oliver Nutter @ <http://headius.blogspot.com>headius.blogspot.com
JRuby Developer @ <http://jruby.sourceforge.net>jruby.sourceforge.net
Application Architect @ <http://www.ventera.com>www.ventera.com
_______________________________________________
Jruby-devel mailing list
Jruby-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jruby-devel
? Apa-0.0.1.gem
? __inst_rake
? collections.patch
? erbtest.rb
? erbtest2.rb
? fcntl.patch
? flash.rb
? java.hprof.txt
? mondo.patch
? oldzlib.rb
? output.profiling
? prj.el
? profilingRakeRdoc1
? profilingTestRdoc2
? rake-0.7.1.gem
? reads_fast.txt
? reads_slow.txt
? rubygems
? signal.patch
? stringio.patch
? testSpeed.rb
? testWebrick.rb
? testWebrick2.rb
? testWebrick3.rb
? zlib.patch
? bin/gem
? bin/gem_mirror
? bin/gem_server
? bin/gemwhich
? bin/generate_yaml_index.rb
? bin/rails
? bin/rake
? bin/update_rubygems
? lib/concurrent.jar
? lib/plaincharset.jar
? src/builtin/zlib.rb
? src/lib/ruby/1.8/oldstringio.rb
? src/org/jruby/RubySignal.java
? src/org/jruby/RubyStringIO.java
? src/org/jruby/RubyZlib.java
? src/org/jruby/internal/runtime/PooledThread.java
? src/org/jruby/libraries/StringIOLibrary.java
? src/org/jruby/libraries/ZlibLibrary.java
? src/org/jruby/util/DummySignalHandler.java
? src/org/jruby/util/ISignal.java
? src/org/jruby/util/SunSignalHandler.java
Index: bin/jruby.bat
===================================================================
RCS file: /cvsroot/jruby/jruby/bin/jruby.bat,v
retrieving revision 1.16
diff -u -r1.16 jruby.bat
--- bin/jruby.bat 14 Jun 2006 14:45:57 -0000 1.16
+++ bin/jruby.bat 16 Jun 2006 15:51:10 -0000
@@ -68,7 +68,7 @@
set _RUNJAVA="%JAVA_HOME%\bin\java"
rem ----- Set Up The Runtime Classpath ----------------------------------------
-set CP=%JRUBY_HOME%\lib\jruby.jar;%JRUBY_HOME%\lib\jvyaml.jar
+set
CP=%JRUBY_HOME%\lib\jruby.jar;%JRUBY_HOME%\lib\jvyaml.jar;%JRUBY_HOME%\lib\plaincharset.jar
if not "%CLASSPATH%" == "" goto gotCP
set CLASSPATH=%CP%
@@ -85,7 +85,9 @@
rem ----- Execute The Requested Command ---------------------------------------
-%_STARTJAVA% -Xmx256m -ea -cp "%CLASSPATH%" -Djruby.base="%JRUBY_BASE%"
-Djruby.home="%JRUBY_HOME%" -Djruby.lib="%JRUBY_HOME%\lib"
-Djruby.shell="cmd.exe" -Djruby.script=jruby.bat org.jruby.Main %JRUBY_OPTS% %*
+rem %_STARTJAVA% -ea -Xmx512M -Xrunhprof:file=output.profiling,cpu=times -cp
"%CLASSPATH%" -Djruby.base="%JRUBY_BASE%" -Djruby.home="%JRUBY_HOME%"
-Djruby.lib="%JRUBY_HOME%\lib" -Djruby.shell="cmd.exe" -Djruby.script=jruby.bat
org.jruby.Main %JRUBY_OPTS% %*
+rem %_STARTJAVA% -ea -Xmx512M
-Xrunhprof:file=output.profiling,cpu=samples,depth=20,interval=5 -cp
"%CLASSPATH%" -Djruby.base="%JRUBY_BASE%" -Djruby.home="%JRUBY_HOME%"
-Djruby.lib="%JRUBY_HOME%\lib" -Djruby.shell="cmd.exe" -Djruby.script=jruby.bat
org.jruby.Main %JRUBY_OPTS% %*
+%_STARTJAVA% -ea -Xmx512M -cp "%CLASSPATH%" -Djruby.base="%JRUBY_BASE%"
-Djruby.home="%JRUBY_HOME%" -Djruby.lib="%JRUBY_HOME%\lib"
-Djruby.shell="cmd.exe" -Djruby.script=jruby.bat org.jruby.Main %JRUBY_OPTS% %*
set E=%ERRORLEVEL%
rem ----- Restore Environment Variables ---------------------------------------
Index: src/builtin/etc.rb
===================================================================
RCS file: /cvsroot/jruby/jruby/src/builtin/etc.rb,v
retrieving revision 1.3
diff -u -r1.3 etc.rb
--- src/builtin/etc.rb 13 Jun 2006 15:26:16 -0000 1.3
+++ src/builtin/etc.rb 14 Jun 2006 06:52:33 -0000
@@ -5,9 +5,3 @@
Struct::Tms.new(0, 0, 0, 0)
end
end
-
-module Signal
- def self.trap(sig)
- # do nothing
- end
-end
\ No newline at end of file
Index: src/builtin/java/collections.rb
===================================================================
RCS file: /cvsroot/jruby/jruby/src/builtin/java/collections.rb,v
retrieving revision 1.4
diff -u -r1.4 collections.rb
--- src/builtin/java/collections.rb 17 Oct 2005 15:02:04 -0000 1.4
+++ src/builtin/java/collections.rb 14 Jun 2006 13:13:00 -0000
@@ -1,35 +1,62 @@
# TODO java.util.Comparator support?
JavaUtilities.extend_proxy('java.util.Map') {
+ include Enumerable
def each(&block)
entrySet.each { |pair| block.call(pair.key, pair.value) }
end
+ def [](key)
+ get(key)
+ end
+ def []=(key,val)
+ put(key,val)
+ val
+ end
}
-JavaUtilities.extend_proxy('java.util.Set') {
+JavaUtilities.extend_proxy('java.lang.Comparable') {
+ include Comparable
+ def <=>(a)
+ compareTo(a)
+ end
+}
+
+JavaUtilities.extend_proxy('java.util.Collection') {
+ include Enumerable
def each(&block)
iter = iterator
while iter.hasNext
block.call(iter.next)
end
end
-}
-
-JavaUtilities.extend_proxy('java.lang.Comparable') {
- include Comparable
- def <=>(a)
- compareTo(a)
+ def <<(a); add(a); self; end
+ def +(oth)
+ nw = self.dup
+ nw.addAll(oth)
+ nw
+ end
+ def -(oth)
+ nw = self.dup
+ nw.removeAll(oth)
+ nw
end
}
-JavaUtilities.extend_proxy('java.util.List') {
- include Enumerable
- def each
-# TODO: With 'def each(&block)' the following line will not work.
-# 0.upto(size-1) { |index| block.call(get(index)) }
- 0.upto(size-1) { |index| yield(get(index)) }
+JavaUtilities.extend_proxy('java.util.List') {
+ def [](ix)
+ if ix < size
+ get(ix)
+ else
+ nil
+ end
+ end
+ def []=(ix,val)
+ if size < ix
+ ((ix-size)+1).times { self << nil }
+ end
+ set(ix,val)
+ val
end
- def <<(a); add(a); end
def sort()
include_class 'java.util.ArrayList'
include_class 'java.util.Collections'
@@ -76,4 +103,4 @@
p = yield(*args)
p p
end
-}
\ No newline at end of file
+}
Index: src/org/jruby/IRuby.java
===================================================================
RCS file: /cvsroot/jruby/jruby/src/org/jruby/IRuby.java,v
retrieving revision 1.17
diff -u -r1.17 IRuby.java
--- src/org/jruby/IRuby.java 15 Jun 2006 14:17:22 -0000 1.17
+++ src/org/jruby/IRuby.java 15 Jun 2006 19:02:51 -0000
@@ -26,6 +26,7 @@
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.load.LoadService;
import org.jruby.util.collections.SinglyLinkedList;
+import org.jruby.util.ISignal;
public interface IRuby {
@@ -352,6 +353,8 @@
public RubyTime newTime(long milliseconds);
+ public ISignal getSignalHandler();
+
public boolean isGlobalAbortOnExceptionEnabled();
public void setGlobalAbortOnExceptionEnabled(boolean b);
@@ -359,4 +362,4 @@
public boolean isDoNotReverseLookupEnabled();
public void setDoNotReverseLookupEnabled(boolean b);
-}
\ No newline at end of file
+}
Index: src/org/jruby/Ruby.java
===================================================================
RCS file: /cvsroot/jruby/jruby/src/org/jruby/Ruby.java,v
retrieving revision 1.123
diff -u -r1.123 Ruby.java
--- src/org/jruby/Ruby.java 16 Jun 2006 02:37:54 -0000 1.123
+++ src/org/jruby/Ruby.java 16 Jun 2006 08:00:13 -0000
@@ -60,6 +60,8 @@
import org.jruby.libraries.JRubyLibrary;
import org.jruby.libraries.RbConfigLibrary;
import org.jruby.libraries.SocketLibrary;
+import org.jruby.libraries.StringIOLibrary;
+import org.jruby.libraries.ZlibLibrary;
import org.jruby.parser.Parser;
import org.jruby.runtime.Block;
import org.jruby.runtime.CacheMap;
@@ -91,6 +93,7 @@
import org.jruby.util.BuiltinScript;
import org.jruby.util.JRubyFile;
import org.jruby.util.collections.SinglyLinkedList;
+import org.jruby.util.ISignal;
/**
* The jruby runtime.
@@ -126,6 +129,8 @@
*/
private int safeLevel = 0;
+ private ISignal signalHandler;
+
// Default classes/objects
private IRubyObject nilObject;
private RubyBoolean trueObject;
@@ -164,6 +169,14 @@
this.in = in;
this.out = out;
this.err = err;
+ try {
+ Class.forName("sun.misc.Signal"); // Check if this is a Sun VM...
+ this.signalHandler =
(ISignal)(Class.forName("org.jruby.util.SunSignalHandler").newInstance());
+ } catch(final Throwable thre) {
+ //Not a Sun VM.
+ this.signalHandler = new org.jruby.util.DummySignalHandler();
+ }
+
init();
}
@@ -423,6 +436,8 @@
loadService.registerBuiltin("jruby", new JRubyLibrary());
+ loadService.registerBuiltin("stringio", new StringIOLibrary());
+ loadService.registerBuiltin("zlib", new ZlibLibrary());
}
private void initCoreClasses() {
@@ -484,6 +499,7 @@
RubyRange.createRangeClass(this);
RubyObjectSpace.createObjectSpaceModule(this);
RubyGC.createGCModule(this);
+ RubySignal.createSignalModule(this);
new ProcMetaClass(this).initializeClass();
@@ -1229,6 +1245,10 @@
return err;
}
+ public ISignal getSignalHandler() {
+ return this.signalHandler;
+ }
+
public boolean isGlobalAbortOnExceptionEnabled() {
return globalAbortOnExceptionEnabled;
}
Index: src/org/jruby/RubyKernel.java
===================================================================
RCS file: /cvsroot/jruby/jruby/src/org/jruby/RubyKernel.java,v
retrieving revision 1.53
diff -u -r1.53 RubyKernel.java
--- src/org/jruby/RubyKernel.java 24 May 2006 01:34:03 -0000 1.53
+++ src/org/jruby/RubyKernel.java 14 Jun 2006 06:43:19 -0000
@@ -657,8 +657,49 @@
throw je;
}
+ private static class JRubyProcObject implements Runnable {
+ private final RubyProc proc;
+ public JRubyProcObject(final RubyProc proc) {
+ this.proc = proc;
+ }
+ public void run() {
+ try {
+ proc.call(new IRubyObject[0]);
+ } catch(final Throwable thre) {
+ // SWALLOW.
+ }
+
+ }
+ }
+
public static IRubyObject trap(IRubyObject recv, IRubyObject[] args) {
- // FIXME: We can probably fake some basic signals, but obviously can't
do everything. For now, stub.
+ String sigName = null;
+ long sigNum = -1;
+ if(args[0] instanceof RubyNumeric) {
+ sigNum = RubyNumeric.num2long(args[0]);
+ } else {
+ sigName = args[0].toString();
+ if(sigName.startsWith("SIG")) {
+ sigName = sigName.substring("SIG".length());
+ }
+ }
+ RubyProc proc = null;
+ if(args.length>1) {
+ if(args[1] instanceof RubyString) {
+ // Handle cases of IGNORE, SIG_IGN, DEFAULT and SIG_DFL
+ } else if(args[1] instanceof RubyProc) {
+ proc = (RubyProc)args[1];
+ }
+ } else {
+ if (recv.getRuntime().getCurrentContext().isBlockGiven()) {
+ proc = recv.getRuntime().newProc();
+ }
+ }
+ if(null != sigName) {
+ recv.getRuntime().getSignalHandler().handleSignal(sigName,new
JRubyProcObject(proc));
+ } else {
+ recv.getRuntime().getSignalHandler().handleSignal(sigNum,new
JRubyProcObject(proc));
+ }
return recv.getRuntime().getNil();
}
Index: src/org/jruby/runtime/callback/ReflectionCallback.java
===================================================================
RCS file:
/cvsroot/jruby/jruby/src/org/jruby/runtime/callback/ReflectionCallback.java,v
retrieving revision 1.14
diff -u -r1.14 ReflectionCallback.java
--- src/org/jruby/runtime/callback/ReflectionCallback.java 24 Nov 2005
16:46:49 -0000 1.14
+++ src/org/jruby/runtime/callback/ReflectionCallback.java 14 Jun 2006
21:34:42 -0000
@@ -168,18 +168,20 @@
assert false : message.toString();
return null;
} catch (final IllegalArgumentException e) {
-/* StringBuffer message = new StringBuffer();
+ StringBuffer message = new StringBuffer();
message.append(e.getMessage());
message.append(':');
message.append(" methodName=").append(methodName);
message.append(" recv=").append(recv.toString());
+ message.append(" recv.class=").append(recv.getClass().getName());
message.append(" type=").append(type.getName());
message.append(" methodArgs=[");
for (int i = 0; i < methodArgs.length; i++) {
message.append(methodArgs[i]);
message.append(' ');
}
- message.append(']');*/
+ message.append(']');
+ System.err.println(message.toString());
assert false : e;
return null;
}
Index: src/org/jruby/util/IOHandlerNio.java
===================================================================
RCS file: /cvsroot/jruby/jruby/src/org/jruby/util/IOHandlerNio.java,v
retrieving revision 1.2
diff -u -r1.2 IOHandlerNio.java
--- src/org/jruby/util/IOHandlerNio.java 30 May 2006 15:52:22 -0000
1.2
+++ src/org/jruby/util/IOHandlerNio.java 16 Jun 2006 15:50:41 -0000
@@ -36,6 +36,7 @@
import java.nio.channels.Channel;
import java.nio.channels.WritableByteChannel;
import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.spi.AbstractSelectableChannel;
import java.nio.channels.FileChannel;
import java.nio.ByteBuffer;
@@ -59,6 +60,9 @@
mode += "r";
isOpen = true;
}
+ if (channel instanceof AbstractSelectableChannel) {
+ ((AbstractSelectableChannel)channel).configureBlocking(false);
+ }
if (channel instanceof WritableByteChannel) {
mode += "w";
isOpen = true;
@@ -104,10 +108,15 @@
ByteBuffer buffer = ByteBuffer.allocate(length);
boolean eof = false;
while (buffer.hasRemaining()) {
- if (((ReadableByteChannel) channel).read(buffer) < 0) {
+ int bytesRead = ((ReadableByteChannel) channel).read(buffer);
+ if (bytesRead < 0) {
eof = true;
break;
}
+ if (bytesRead == 0) {
+ // only should happen for nonblocking IO...break and allow the
next call to try again
+ break;
+ }
}
if (buffer.position() == 0 && eof == true) {
throw new EOFException();
Index: src/org/jruby/util/IOInputStream.java
===================================================================
RCS file: /cvsroot/jruby/jruby/src/org/jruby/util/IOInputStream.java,v
retrieving revision 1.2
diff -u -r1.2 IOInputStream.java
--- src/org/jruby/util/IOInputStream.java 9 Apr 2006 20:58:31 -0000
1.2
+++ src/org/jruby/util/IOInputStream.java 15 Jun 2006 10:18:24 -0000
@@ -68,12 +68,30 @@
IRubyObject readValue = io.callMethod("read", numOne);
int returnValue = -1;
if(!readValue.isNil()) {
- RubyArray unpackValue = (RubyArray) readValue.callMethod("unpack",
packArg);
- IRubyObject firstCharacter = unpackValue.entry(0);
- if(!firstCharacter.isNil()) {
- returnValue = (int)((RubyFixnum)
firstCharacter).getLongValue();
- }
+ returnValue = readValue.toString().charAt(0);
}
return returnValue;
}
+
+ public int read(final byte[] b) throws IOException {
+ IRubyObject readValue = io.callMethod("read",
this.io.getRuntime().newFixnum(b.length));
+ int returnValue = -1;
+ if(!readValue.isNil()) {
+ final String str = readValue.toString();
+ System.arraycopy(str.getBytes("PLAIN"),0,b,0,str.length());
+ returnValue = str.length();
+ }
+ return returnValue;
+ }
+
+ public int read(final byte[] b,final int off, final int len) throws
IOException {
+ IRubyObject readValue = io.callMethod("read",
this.io.getRuntime().newFixnum(len));
+ int returnValue = -1;
+ if(!readValue.isNil()) {
+ final String str = readValue.toString();
+ System.arraycopy(str.getBytes("PLAIN"),0,b,off,str.length());
+ returnValue = str.length();
+ }
+ return returnValue;
+ }
}
Index: src/org/jruby/util/IOOutputStream.java
===================================================================
RCS file: /cvsroot/jruby/jruby/src/org/jruby/util/IOOutputStream.java,v
retrieving revision 1.2
diff -u -r1.2 IOOutputStream.java
--- src/org/jruby/util/IOOutputStream.java 9 Apr 2006 20:58:31 -0000
1.2
+++ src/org/jruby/util/IOOutputStream.java 15 Jun 2006 18:22:47 -0000
@@ -61,4 +61,12 @@
public void write(final int bite) throws IOException {
io.callMethod("write", io.getRuntime().newString(new String(new
char[]{(char)(0x000000FF & bite)})));
}
+
+ public void write(final byte[] b) throws IOException {
+ write(b,0,b.length);
+ }
+
+ public void write(final byte[] b,final int off, final int len) throws
IOException {
+ io.callMethod("write",io.getRuntime().newString(new
String(b,off,len,"PLAIN")));
+ }
}
Index: test/testStringIO.rb
===================================================================
RCS file: /cvsroot/jruby/jruby/test/testStringIO.rb,v
retrieving revision 1.10
diff -u -r1.10 testStringIO.rb
--- test/testStringIO.rb 26 May 2006 01:20:38 -0000 1.10
+++ test/testStringIO.rb 11 Jun 2006 18:13:27 -0000
@@ -11,7 +11,6 @@
lines = []
3.times {lines << strio.readline}
-
test_equal(["one\n", "two\n", "three\n"], lines)
##### gets #####
@@ -33,7 +32,7 @@
#$_='G'
#s.print
s.printf("a %s b\n", 1)
-
+$\=nil
test_equal(<<EOF, s.string)
1
2
@@ -124,6 +123,7 @@
test_equal("HEL\n", n.gets)
$stdout = old_stdout
n = StringIO.new
+old_var = $>
$> = n
puts "HEL\nEEEE\n"
n.rewind
@@ -131,3 +131,4 @@
n = StringIO.new("123\n456\n789\n")
test_equal("123\n456\n789\n", n.gets(nil))
+$> = old_var
Index: test/testZlib.rb
===================================================================
RCS file: /cvsroot/jruby/jruby/test/testZlib.rb,v
retrieving revision 1.2
diff -u -r1.2 testZlib.rb
--- test/testZlib.rb 26 Mar 2006 21:21:40 -0000 1.2
+++ test/testZlib.rb 15 Jun 2006 18:48:32 -0000
@@ -17,4 +17,4 @@
test_equal("bar\n", z.gets)
z.close
-File.unlink(filename)
+File.delete(filename)
_______________________________________________
Jruby-devel mailing list
Jruby-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jruby-devel