harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anton Avtamonov <anton.avtamo...@gmail.com>
Subject Re: Mission impossible: new APIs without spec in Java 5.0
Date Thu, 16 Feb 2006 13:24:32 GMT
On 2/16/06, Tim Ellison <t.p.ellison@gmail.com> wrote:
> Hmm, they look to me like they could be impl methods that were
> inadvertently exposed.  They don't seem to fit in to the BreakIterator bag.
>
> If I were you I'd implement them to throw a NotYetImplementedException.
>
> Regards,
> Tim
>

I agree that those methods are a bit strange... Does the proposed
exception well fit to the compatibility strategy? As I know once the
method was exposed it will never be removed from spec and therefore
everyone can use it...

I did 5 min research and found that their implementation should be
very simple (sorry I provide the test not in JUnit format):

Method getInt = BreakIterator.class.getDeclaredMethod("getInt", new
Class[] {new byte[0].getClass(), Integer.TYPE});
getInt.setAccessible(true);

Object result = getInt.invoke(null, new Object[] {new byte[] {0, 0, 0,
1, 1, 0}, new Integer(0)});
System.err.println("expected 1 = " + (new Integer(1).equals(result)));

result = getInt.invoke(null, new Object[] {new byte[] {0, 0, 0, 1, 1,
0}, new Integer(1)});
System.err.println("expected 257 = " + (new Integer(257).equals(result)));

result = getInt.invoke(null, new Object[] {new byte[] {0, 0, 0, 1, 10,
0}, new Integer(1)});
System.err.println("expected 266 = " + (new Integer(266).equals(result)));

IMHO, it is not very difficult to implement.

--
Anton Avtamonov,
Intel Middleware Products Division

Mime
View raw message