Re: Mission impossible: new APIs without spec in Java 5.0
Hello Anton, Thanks a lot. Yes, we can use test to investigate the behavior of RI. :-) Richard Liang China Software Development Lab, IBM Anton Avtamonov wrote: On 2/16/06, Tim Ellison [EMAIL PROTECTED] 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
Re: Mission impossible: new APIs without spec in Java 5.0
Hi, What is wrong if you prepare unit tests and investigate how it works? I think that is valid approach for such cases. Am I wrong? -- Anton Avtamonov, Intel Middleware Products Division On 2/16/06, Richard Liang [EMAIL PROTECTED] wrote: Dears, There are three protected methods added in java.text.BreakIterator, but I cannot find their specification. What shall we do? protected static long getLong(byte[] buf, int offset) protected static int getInt(byte[] buf, int offset) protected static short getShort(byte[] buf, int offset) -- Richard Liang China Software Development Lab, IBM
Re: Mission impossible: new APIs without spec in Java 5.0
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 Anton Avtamonov wrote: Hi, What is wrong if you prepare unit tests and investigate how it works? I think that is valid approach for such cases. Am I wrong? -- Anton Avtamonov, Intel Middleware Products Division On 2/16/06, Richard Liang [EMAIL PROTECTED] wrote: Dears, There are three protected methods added in java.text.BreakIterator, but I cannot find their specification. What shall we do? protected static long getLong(byte[] buf, int offset) protected static int getInt(byte[] buf, int offset) protected static short getShort(byte[] buf, int offset) -- Richard Liang China Software Development Lab, IBM -- Tim Ellison ([EMAIL PROTECTED]) IBM Java technology centre, UK.
Re: Mission impossible: new APIs without spec in Java 5.0
Richard Liang wrote: Dears, There are three protected methods added in java.text.BreakIterator, but I cannot find their specification. What shall we do? protected static long getLong(byte[] buf, int offset) protected static int getInt(byte[] buf, int offset) protected static short getShort(byte[] buf, int offset) Guess :-) -- Stefano.