0
http://samuraism.jp/              @yusukeyCopyright(c) Yusuke Yamamoto All rights reserved.
Java                       Twitter APIBSD                                   : 2.1.10                                      ...
Android                 2010/1/17                      @yusukey   Copyright(c) Yusuke Yamamoto All rights reserved.
Android• Sun• XML• JSON         Copyright(c) Yusuke Yamamoto All rights reserved.
new sun.misc.BASE64Encoder().encode(buf);02-20 18:03:59.843: WARN/dalvikvm(526): VFY: unable to resolvenew-instance 105 (L...
• BASE64  (Commons-Codec                                       ok)• sun.misc.*                                com.sun.*   ...
XML   •   Twitter4J// XMLprivate String toString(Element doc){  StringWriter output = new StringWriter();  Transformer t =...
07-07 23:55:42.993: ERROR/dalvikvm(11182): Could not find methodjavax.xml.transform.TransformerFactory.newInstance, refere...
// XMLprivate static String toString(Element doc){ StringWriter output = new StringWriter(); try{  Transformer t = Transfo...
01-16 23:20:58.637: ERROR/AndroidRuntime(209): Uncaught handler: thread main exitingdue to uncaught exception01-16 23:20:5...
-- // XML-- private static String toString(Element doc){-- StringWriter output = new StringWriter();-- try{-- Transformer ...
XMLString xml = "<title>English &amp;                        </title>";DocumentBuilderFactory dbf = DocumentBuilderFactory...
String xml = "<title>English &amp;                        </title>";DocumentBuilderFactory dbf = DocumentBuilderFactory.ne...
XMLCopyright(c) Yusuke Yamamoto All rights reserved.
JSON• Twitter       xml, JSON, atom, rss• JSON •   JavaScript Object Notation •   Web API               Twitter4J         ...
JSON(“foo”:null, “longvalue”:”13857270119014401”}JSONObject json = new JSONObject   ("{"foo":null,"longvalue":"13857270119...
JSONObject json = new JSONObject   ("{"foo":null,"longvalue":"13857270119014401"}");// true                               ...
json.org           twitter4j.internal.org.json.*           Copyright(c) Yusuke Yamamoto All rights reserved.
•   XSLT                    (Froyo                               )•                                                     Ve...
• Androidpublic static final boolean IS_DALVIK;static{  try {    // dalvik.system.VMRuntime class should be existing onAnd...
- Issue 2607 - android - org.apache.harmony.xml.parsers.DocumentBuilderImpl does notresolve unicode entity refshttp://code...
Androidの本当にあった怖い話
Androidの本当にあった怖い話
Androidの本当にあった怖い話
Upcoming SlideShare
Loading in...5
×

Androidの本当にあった怖い話

23,374

Published on

Published in: Technology, News & Politics
1 Comment
15 Likes
Statistics
Notes
  • XMLとかJSONが素ではバグが潜んでて危険とか、ちょっと怖い。テストで気をつけなきゃ。
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
23,374
On Slideshare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
39
Comments
1
Likes
15
Embeds 0
No embeds

No notes for slide

Transcript of "Androidの本当にあった怖い話"

  1. 1. http://samuraism.jp/ @yusukeyCopyright(c) Yusuke Yamamoto All rights reserved.
  2. 2. Java Twitter APIBSD : 2.1.10 : • JDK1.4.2 • Google App Engine • Android Copyright(c) Yusuke Yamamoto All rights reserved.
  3. 3. Android 2010/1/17 @yusukey Copyright(c) Yusuke Yamamoto All rights reserved.
  4. 4. Android• Sun• XML• JSON Copyright(c) Yusuke Yamamoto All rights reserved.
  5. 5. new sun.misc.BASE64Encoder().encode(buf);02-20 18:03:59.843: WARN/dalvikvm(526): VFY: unable to resolvenew-instance 105 (Lsun/misc/BASE64Encoder;) in Ltwitter4j/http/HttpClient;02-20 18:03:59.843: WARN/dalvikvm(526): VFY: rejecting opcode0x22 at 0x0011 :Android sun.misc.* / com.sun.* Copyright(c) Yusuke Yamamoto All rights reserved.
  6. 6. • BASE64 (Commons-Codec ok)• sun.misc.* com.sun.* Copyright(c) Yusuke Yamamoto All rights reserved.
  7. 7. XML • Twitter4J// XMLprivate String toString(Element doc){ StringWriter output = new StringWriter(); Transformer t =TransformerFactory.newInstance() .newTransformer(); t.transform(new DOMSource(doc), new StreamResult(output)); return output.toString();} Copyright(c) Yusuke Yamamoto All rights reserved.
  8. 8. 07-07 23:55:42.993: ERROR/dalvikvm(11182): Could not find methodjavax.xml.transform.TransformerFactory.newInstance, referenced from method twitter4j.TwitterResponse.toString :Android XSLT Copyright(c) Yusuke Yamamoto All rights reserved.
  9. 9. // XMLprivate static String toString(Element doc){ StringWriter output = new StringWriter(); try{ Transformer t = TransformerFactory.newInstance().newTransformer(); t.transform(new DOMSource(doc), new StreamResult(output)); return output.toString(); }catch(ClassNotFoundException cnfe){ // javax.xml.transform.TransformerFactory // “” return “”; }} Copyright(c) Yusuke Yamamoto All rights reserved.
  10. 10. 01-16 23:20:58.637: ERROR/AndroidRuntime(209): Uncaught handler: thread main exitingdue to uncaught exception01-16 23:20:58.668: ERROR/AndroidRuntime(209): java.lang.VerifyError:com.example.MyActivity at java.lang.Class.newInstanceImpl(Native Method) at java.lang.Class.newInstance(Class.java:1472) at android.app.Instrumentation.newActivity(Instrumentation.java:1097) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2316) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417) at android.app.ActivityThread.access$2100(ActivityThread.java:116) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:4203) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549) at dalvik.system.NativeStart.main(Native Method) : VerifyError Copyright(c) Yusuke Yamamoto All rights reserved.
  11. 11. -- // XML-- private static String toString(Element doc){-- StringWriter output = new StringWriter();-- try{-- Transformer t = TransformerFactory.newInstance().newTransformer();-- t.transform(new DOMSource(doc),-- new StreamResult(output));-- return output.toString();-- }catch(ClassNotFoundException cnfe){-- // javax.xml.transform.TransformerFactory-- // “”-- return “”;-- }--} Transformer Copyright(c) Yusuke Yamamoto All rights reserved.
  12. 12. XMLString xml = "<title>English &amp; </title>";DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();dbf.setCoalescing(true);dbf.setExpandEntityReferences(true);ByteArrayInputStream stream = new ByteArrayInputStream( xml.getBytes());DocumentBuilder builder = null;builder = dbf.newDocumentBuilder();Document doc = builder.parse(stream);Node titleNode = doc.getFirstChild();NodeList children = titleNode.getChildNodes();System.out.println(children.item(0).getTextContent()); : “English & ” : “English” Copyright(c) Yusuke Yamamoto All rights reserved.
  13. 13. String xml = "<title>English &amp; </title>";DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();dbf.setCoalescing(true);dbf.setExpandEntityReferences(true);ByteArrayInputStream stream = new ByteArrayInputStream( xml.getBytes());DocumentBuilder builder = null;builder = dbf.newDocumentBuilder();Document doc = builder.parse(stream);Node titleNode = doc.getFirstChild();NodeList children = titleNode.getChildNodes();System.out.println(children.item(0).getTextContent()); :XML Copyright(c) Yusuke Yamamoto All rights reserved.
  14. 14. XMLCopyright(c) Yusuke Yamamoto All rights reserved.
  15. 15. JSON• Twitter xml, JSON, atom, rss• JSON • JavaScript Object Notation • Web API Twitter4J JSON Copyright(c) Yusuke Yamamoto All rights reserved.
  16. 16. JSON(“foo”:null, “longvalue”:”13857270119014401”}JSONObject json = new JSONObject ("{"foo":null,"longvalue":"13857270119014401"}");// trueSystem.out.println(json.isNull("foo"));// trueSystem.out.println(null == json.getString("foo"));// falseSystem.out.println("null".equals(json.getString("foo")));// 13857270119014401System.out.println(json.getLong("longvalue")); Copyright(c) Yusuke Yamamoto All rights reserved.
  17. 17. JSONObject json = new JSONObject ("{"foo":null,"longvalue":"13857270119014401"}");// true trueSystem.out.println(json.isNull("foo"));// true trueSystem.out.println(null == json.getString("foo"));// false trueSystem.out.println("null".equals(json.getString("foo")));// 13857270119014401 13857270119014400System.out.println(json.getLong("longvalue")); :json Copyright(c) Yusuke Yamamoto All rights reserved.
  18. 18. json.org twitter4j.internal.org.json.* Copyright(c) Yusuke Yamamoto All rights reserved.
  19. 19. • XSLT (Froyo )• VerifyError • Eclair(Android 2.1)• XML • Froyo(Android 2.2)• JSON •• Sun Copyright(c) Yusuke Yamamoto All rights reserved.
  20. 20. • Androidpublic static final boolean IS_DALVIK;static{ try { // dalvik.system.VMRuntime class should be existing onAndroid platform. // @see http://developer.android.com/reference/dalvik/system/VMRuntime.html Class.forName("dalvik.system.VMRuntime"); dalvikDetected = true; } catch (ClassNotFoundException cnfe) { dalvikDetected = false"; } IS_DALVIK = dalvikDetected;} Copyright(c) Yusuke Yamamoto All rights reserved.
  21. 21. - Issue 2607 - android - org.apache.harmony.xml.parsers.DocumentBuilderImpl does notresolve unicode entity refshttp://code.google.com/p/android/issues/detail?id=2607- Issue 9244 - android - org.json packages out of datehttp://code.google.com/p/android/issues/detail?id=9244- Issue 13830 - JSONObject.getString() returns "null" string literal for null valueinstead of null object.http://code.google.com/p/android/issues/detail?id=13830- Issue 13831 - JSONObject.getLong() returns rounded and inaccurate valuehttp://code.google.com/p/android/issues/detail?id=13831 Copyright(c) Yusuke Yamamoto All rights reserved.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×