Optimize key-based Hash access for empty hashes

This avoids performing the potentially expensive hash computation in
the event that the Hash is empty, as there cannot possibly be a match.
Conform to MRI behaviour for empty hashes

In the event that the `#hash` method has side effects, any optimisation
with respect to empty hashes will affect the results of the operations.

For MRI, the empty-hash optimisation seems to be applied everywhere in
2.0.0 and beyond. In 1.9.3 the #hash method is not called for #[] and
#key?, but strangely enough the performance is not improved for empty
hashes. In 1.8.7, the #hash method is always called even if empty.

This does not match the semantics of MRI exactly, as this avoids calling
the #hash method from #values_at in 1.9.3, but that would be slightly
more involved to implement.
Fix ServerSocket#accept_nonblock to return a correct Sockaddr

ServerSocket#accept_nonblock should return a Sockaddr with the remote port, not the local port.

This closes #1777
Fix BigDecimal#round behavior with NAN and INFINITY

When we call round without any argument on BigDecimal::NAN or
BigDecimal::INFINITY, a FloatDomainError should be raised.

Otherwise, the number shouldn't be altered. The problem is that JRuby
defines these constants according to BigDecimal.ZERO so when we apply
the rounding on it, it returns a float form of 0. Thus, we need to
short-circuit that and return the constant itself.
Merge pull request #1808 from robin850/bigdecimal-round

Fix BigDecimal#round behavior with NAN and INFINITY
Merge pull request #1778 from iconara/fix_1777

Fix #1777: ServerSocket#accept_nonblock to return a correct Sockaddr
Mask spec that uses 1.9 methods.
Before a native, in-process exec, shut down JMX agent.

If the JRuby JVM is started with the remote JMX agent enabled,
subsequence native exec of JRuby (basically restarting JRuby in
the same process space) can fail because the port remains bound.
This change uses internal OpenJDK classes to shut down the JMX
agent before a native exec, so it can restart in the new JVM.

A side effect of this is that if native exec fails, we must
attempt to restart the agent as well. This will break connections
for existing clients, but they would have lost connection had the
exec succeeded. I don't see this as a problem.

Fixes #1859.
Re-register our beans if we have to restart agent on failed exec.
Use options-1.2-SNAPSHOT until it propagates.

Conflicts:
	core/pom.xml
find builtin libraries on any classloader
added comment test case for ffi and osgi [skip ci]
* stay within the classpath: protocol

* unsure we pass on the Url with its URLStreamHandler provided by the classloader directly to the JRubyClassloader

remark on the URL:
currently there are plenty of issues where those embedded jars from jruby-stdlib
can not be loaded. AND if somehting goes wrong adding that URL to the JRubyClassloader
there will be no Exception so the actual error pops as some constant not found or
some import_java does not work. turning on debug.loadService often shows that jar could
be found and still it is not working. URL -> toString -> new URL( String ) is not reliable since
you always can construct URL objects with "custom" URLStreamHandler. the idea here to
just take whatever URL the classloader produces and pass it on the JRubyClassloader.
added the same readonly-fileStats to URLResource and ClasspathResource as JarResource has.
added directory listing info the jruby-stdlib.jar so ClasspathResource and URLResource
can use them to setup directory FileResource

with this the OSGiSCriptingConstainer and also the ScriptingContainer inside an OSGi bundle have
not default gems. most probably other J2EEContainer which do not "see" defaults gems with jruby-1.7.13
should see them now.

embedded gems will also work when they embedded directory supply a .jrubydir file with the directory listing.
integration test is not supplied here.

testing is currenly limited to high level integration tests
Merge pull request #1676 from grddev/empty-hash-optimization

Empty hash optimization
[trivial] Make single-line ifs and make getEntry read as !18
options-1.2 has propagated.
Revert "added directory listing info the jruby-stdlib.jar so ClasspathResource and URLResource"

This reverts commit c04c50f67ae8c80d52d86ee74100a063bb036c2b.
Handle CancelledKeyException in IO.select

When a CancelledKeyException is raised in IO.select/SelectBlob#processSelectedKeys it caught, but the catch block causes another one to be raised immediately. This patch removes the catch block completely (because it's never run, so nothing can rely on what it does) and raises an Errno::EBADF from SelectBlob#goForIt.

CancelledKeyException is raised when the underlying channel has closed, which is normally handled. There is however a race condition in the channel selection that means that you can get a cancelled key from select if the channel is closed just after the selector determines that it is ready to read or write.

It's unclear what the correct way of handling this really is, but raising EBADF feels reasonable, the channel has been closed and so it's no longer a valid file descriptor.

This closes #1580