Commit Graph

3543 Commits

Author SHA1 Message Date
Johannes Schindelin
167688eabd Teach SystemClassLoader#getResources to not stop at the first match
The getResources method can be used to find all matches in the class
path for a given path, e.g. to seek out all the META-INF/MANIFEST.MF
files contained in all of the .jar files in the class path.

We just taught the findResources() method to return all matches (rather
than only the first), so let's use that method to get all the matches
from the current class loader's class path elements.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-04 16:49:34 -06:00
Johannes Schindelin
0602d4a447 Consider all class path elements in SystemClassLoader#findResources
The findResources method is supposed to enumerate all the class path
elements' matching paths' URLs, but we used to stop at the first one.

While this is good enough when the system class path contains only a
single .jar file, since b88438d2(sketch of JAR support in Finder)
supports more than a single .jar file in the class path.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-04 16:49:31 -06:00
Johannes Schindelin
1864180ea7 Teach Finder to find more than just the first matching element
When the system class path contains more than one .jar, it is quite
concievable that, say, 'META-INF/MANIFEST.MF' can be found in multiple
class path elements.

This commit teaches the working horse of class path inspection, the
Finder class, how to continue the search at a given state.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-11-04 16:44:52 -06:00
Johannes Schindelin
6c46fe3f1a Make Vector a Cloneable
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-25 15:32:33 -05:00
Johannes Schindelin
056c65947e Add Collections#singletonList
This is a very dumb implementation that wastes space and time by
constructing a full-blown ArrayList as backend. However, it is
better to have a dumb implementation than none at all, and we can
always do something about the performance when, and if, that should
become necessary.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-25 15:32:33 -05:00
Johannes Schindelin
86c735e649 Add Collections#synchronizedSet
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-25 15:32:33 -05:00
Johannes Schindelin
526dd574d9 Add the Method#isVarArgs method
Required by bleeding-edge Beanshell...

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-25 15:32:33 -05:00
Johannes Schindelin
0e3e719dd6 Add the Boolean#getBoolean method
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-25 15:32:33 -05:00
Johannes Schindelin
95fcc9ac8e Test the newly-introduced Integer#decode method
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-25 15:32:33 -05:00
Johannes Schindelin
d04cda30ca Add the Integer#decode method
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-25 15:32:33 -05:00
Johannes Schindelin
c1ec6020a6 Verify that String#lastIndexOf handles large fromIndex correctly
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-25 15:32:33 -05:00
Johannes Schindelin
2ff0178da4 Adjust fromIndex in String#lastIndexOf if necessary
If fromIndex 'is greater than or equal to the length of this string,
it has the same effect as if it were equal to one less than the length
of the string':

http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#lastIndexOf%28int,%20int%29

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-25 15:32:33 -05:00
Johannes Schindelin
6f64e3aaab Verify that two-dimensional object arrays have the correct component type
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-25 15:32:33 -05:00
Johannes Schindelin
0ca8601777 Fix getClass().getComponentType() for higher-dimensional arrays
When creating an object array with more than two dimensions, the
component type was erroneously set to the base type, not the array
type of one less dimension.

This prevented Collection<Class[]>#toArray(Class[][]) from working
properly.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-25 15:31:54 -05:00
Joshua Warner
187d5dfde9 fix darwin build 2013-10-24 14:07:53 -06:00
Joshua Warner
b20dcd268c Merge pull request #85 from dscho/simple-regex
Simple regex
2013-10-21 13:30:57 -07:00
Johannes Schindelin
359f99c0f7 Add a unit test for regular expressions
We do not really support regular expressions yet, but we do support
trivial patterns including ones with escaped characters. Let's make sure
that that works as advertised.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-21 13:34:33 -05:00
Johannes Schindelin
728473e9ad Support escaped octal and hexadecimal characters in regular expressions
In the previous commit, we did not support characters in regular
expressions specified via \0..., \x... or \u... yet. This is a bit more
involved, therefore support for them is added in its own commit.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-21 13:34:33 -05:00
Johannes Schindelin
f55ac46602 Support trivial regular expressions with special escaped characters
When a regular expression contains escaped characters such as the
backslash, it is actually still a literal string. So let's support the
trivially-escaped characters, too, that are documented in

	http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-21 12:00:17 -05:00
Joshua Warner
02e433ce61 Merge pull request #84 from dscho/random-access-file
Write support for the RandomAccessFile
2013-10-21 09:38:44 -07:00
Joshua Warner
e485a468f0 Merge pull request #82 from dscho/dates
Implement date parsing / formatting
2013-10-21 09:36:46 -07:00
Johannes Schindelin
3681ae508e Implement a rudimentary RandomAccessFile#getChannel
This implementation is by no means intended to be complete, just enough to
support running http://http://loci.wisc.edu/software/bio-formats's
loci.formats.tools.ImageConverter tool.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-21 10:59:59 -05:00
Johannes Schindelin
3a67f81b50 Add the FileChannel class
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-21 10:59:59 -05:00
Johannes Schindelin
caec6eba67 Add the BufferUnderflowException
Pre-compiled code might expect the class to exist...

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-21 10:59:59 -05:00
Johannes Schindelin
4f83f8dd98 ByteBuffer: add missing order() methods
Avian's ByteBuffer implementation is actually fixed to big endian. So
let's throw an exception if the user tries to change that.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-21 10:59:59 -05:00
Johannes Schindelin
320fc511dc Fix potential memory leak in RandomAccessFile#readBytes
This was noticed when copy-editing writeBytes.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-21 10:59:59 -05:00
Johannes Schindelin
8084cb6398 Fix indentation in java-io.cpp
This was noticed when copy-editing readBytes into writeBytes.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-21 10:59:59 -05:00
Johannes Schindelin
2c0a1c726d Add write support for RandomAccessFile
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-21 10:59:59 -05:00
Johannes Schindelin
905ddfe613 Add the RandomAccessFile(File file, String mode) constructor
As per the Java API.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-21 10:59:58 -05:00
Johannes Schindelin
18f6f7881a RandomAccessFile: support opening for read/write
So far, we only allowed opening in read-only mode. Now, we also support
read/write mode in addition.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-21 10:55:26 -05:00
Johannes Schindelin
db99aada94 Test date parsing/formatting
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-21 10:41:40 -05:00
Johannes Schindelin
4f8b3f8865 Implement a minimal SimpleDateFormat
For the moment, this class can only handle dates of the form
"yyyy-MM-dd'T'HH:mm:ss".

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-21 10:41:40 -05:00
Joshua Warner
bbdb3f7136 Merge pull request #86 from dscho/data-output-stream
Data output stream
2013-10-18 15:59:40 -07:00
Joshua Warner
c0d5328da0 Merge pull request #83 from dscho/some-missing-methods
Add some missing methods
2013-10-18 15:59:20 -07:00
Johannes Schindelin
c46baa3524 Add a minimal implementation of DataOutputStream
This implements all the methods required by the DataOutput interface; to
run Bio-Formats' bfconvert tool, actually only the write() and writeByte()
methods would be required.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-18 15:10:05 -05:00
Johannes Schindelin
2f87be954c Add the DataInput / DataOutput interfaces
These are part of the standard Java class library API.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-18 15:10:05 -05:00
Johannes Schindelin
6f9a9fd15d Add java.lang.Double#doubleToLongBits
It is different than #doubleToRawLongBits only when the input value
is not a number.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-18 15:01:36 -05:00
Johannes Schindelin
a9ecf1eaed Complete the java.util.Arrays#toString family of methods
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-18 15:01:36 -05:00
Johannes Schindelin
396c0822cd Add java.lang.Character#isISOControl(char)
... as per the public JavaDoc at

http://docs.oracle.com/javase/6/docs/api/java/lang/Character.html#isISOControl%28char%29

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-18 15:01:36 -05:00
Johannes Schindelin
7aca1b1307 Add java.lang.Boolean#parse(String)
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-18 15:01:36 -05:00
Johannes Schindelin
7476603e1c Add minimal implementations of ParseException / ParsePosition
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-18 14:58:44 -05:00
Johannes Schindelin
dcfcd193be Implement Calendar#getTime
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-18 14:58:44 -05:00
Johannes Schindelin
466a7fc0c0 Be more verbose when complaining about a non-trivial regex
In particular when constructing regular expressions before compiling them,
it is a good idea to state which exact expression is non-trivial when
complaining about it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-18 14:56:05 -05:00
Joshua Warner
b3d4f33522 fix memory leak in Java_java_io_File_lastModified (exposed in debug mode) 2013-10-17 13:54:59 -06:00
Joshua Warner
526e3a41a8 Merge pull request #81 from dscho/last-modified
Fix unsatisfied link error when calling java.io.File#lastModified on non-Windows
2013-10-17 12:38:06 -07:00
Johannes Schindelin
974073ed17 Make sure to test java.io.File#lastModified
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-17 14:30:41 -05:00
Johannes Schindelin
ba10a58e3b Support java.io.File#lastModified not only on Windows
There was already non-Windows support, but it was put into the
Windows-specific part. Move it outside.

While at it, change the left-over 'st' to 'fileStat' to fix the
compilation.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2013-10-17 14:22:59 -05:00
Joshua Warner
4285d84406 fix windows.cpp compile for newer versions of mingw 2013-09-11 09:30:35 -06:00
Joshua Warner
314f18644f make getChars and releaseChars static, to prevent them being confused with implementations in other objects if they're not inlined (debug mode) 2013-09-06 08:47:46 -06:00
Joshua Warner
3136c9d156 fix ios sim=true build 2013-09-03 21:22:34 -06:00