SlideShare a Scribd company logo
1 of 24
Download to read offline
Android
                 2011/1/17
                      @yusukey




   Copyright(c) Yusuke Yamamoto All rights reserved.
http://samuraism.jp/
                      @yusukey



http://tinyurl.com/android-java
          Copyright(c) Yusuke Yamamoto All rights reserved.
↑
Java Twitter API


  • JDK1.4.2
  • Google App Engine
  • Android
      Copyright(c) Yusuke Yamamoto All rights reserved.
Android Java



      Copyright(c) Yusuke Yamamoto All rights reserved.
Android




    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 resolve
new-instance 105 (Lsun/misc/BASE64Encoder;) in Ltwitter4j/http/
HttpClient;
02-20 18:03:59.843: WARN/dalvikvm(526): VFY: rejecting opcode
0x22 at 0x0011



              :Android               sun.misc.* / com.sun.*


                   Copyright(c) Yusuke Yamamoto All rights reserved.
• BASE64
  (Commons-Codec                                       ok)


• sun.misc.*                                com.sun.*




           Copyright(c) Yusuke Yamamoto All rights reserved.
XML



 Copyright(c) Yusuke Yamamoto All rights reserved.
XML
   •   Twitter4J
// XML
private 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.
07-07 23:55:42.993: ERROR/dalvikvm(11182): Could not find method
javax.xml.transform.TransformerFactory.newInstance,
 referenced from method twitter4j.TwitterResponse.toString




                  :Android                  XSLT




                   Copyright(c) Yusuke Yamamoto All rights reserved.
// 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 “”;
    }
}
                     Copyright(c) Yusuke Yamamoto All rights reserved.
01-16 23:20:58.637: ERROR/AndroidRuntime(209): Uncaught handler: thread main exiting
due to uncaught exception
01-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.
-- // 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.
XML
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());




                   Copyright(c) Yusuke Yamamoto All rights reserved.
String xml = "<title>English &amp;                        </title>";
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance
();
dbf.setCoalescing(true);
dbf.setExpandEntityReferences(true);
ByteArrayInputStream stream = new &
                       : “English ByteArrayInputStream(
                                           ”
        xml.getBytes());
DocumentBuilder builder = “English”
                     :     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.
XML




Copyright(c) Yusuke Yamamoto All rights reserved.
• Twitter       xml, JSON, atom, rss

• JSON
 •   JavaScript Object Notation
 •   Web API




               Twitter4J              JSON



               Copyright(c) Yusuke Yamamoto All rights reserved.
JSON



 Copyright(c) Yusuke Yamamoto All rights reserved.
JSON
(“foo”:null, “longvalue”:”13857270119014401”}

JSONObject json = new JSONObject
   ("{"foo":null,"longvalue":"13857270119014401"}");
// true
System.out.println(json.isNull("foo"));
// true

System.out.println(null == json.getString("foo"));
// false
System.out.println("null".equals(json.getString("foo")));
// 13857270119014401
System.out.println(json.getLong("longvalue"));

                 Copyright(c) Yusuke Yamamoto All rights reserved.
JSONObject json = new JSONObject
   ("{"foo":null,"longvalue":"13857270119014401"}");
// true                                            true
System.out.println(json.isNull("foo"));
// true                                            true
System.out.println(null == json.getString("foo"));
// false                                           true
System.out.println("null".equals(json.getString("foo")));
// 13857270119014401                            13857270119014400
System.out.println(json.getLong("longvalue"));


                 :json

                 Copyright(c) Yusuke Yamamoto All rights reserved.
json.org
           twitter4j.internal.org.json.*




           Copyright(c) Yusuke Yamamoto All rights reserved.
•   XSLT                    (Froyo                               )

•                                                     VerifyError

    •   Eclair(Android 2.1)

•   XML

    •   Froyo(Android 2.2)

•   JSON

    •
•   Sun
             Copyright(c) Yusuke Yamamoto All rights reserved.
• Android
public static final boolean IS_DALVIK;
static{
  try {
    // dalvik.system.VMRuntime class should be existing on
Android 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.
- Issue 2607 - android -
org.apache.harmony.xml.parsers.DocumentBuilderImpl does not
resolve unicode entity refs
http://code.google.com/p/android/issues/detail?id=2607

- Issue 9244 - android - org.json packages out of date
http://code.google.com/p/android/issues/detail?id=9244

- Issue 13830 - JSONObject.getString() returns "null" string
literal for null value instead of null object.
http://code.google.com/p/android/issues/detail?id=13830

- Issue 13831 - JSONObject.getLong() returns rounded and
inaccurate value
http://code.google.com/p/android/issues/detail?id=13831


                   Copyright(c) Yusuke Yamamoto All rights reserved.

More Related Content

What's hot

Django & Buildout (en)
Django & Buildout (en)Django & Buildout (en)
Django & Buildout (en)
zerok
 
Introduction to zc.buildout
Introduction to zc.buildoutIntroduction to zc.buildout
Introduction to zc.buildout
Ricardo Newbery
 
Testing of javacript
Testing of javacriptTesting of javacript
Testing of javacript
Lei Kang
 

What's hot (20)

"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
"Applied Enterprise Metaprogramming in JavaScript", Vladyslav Dukhin
 
Startup groovysession1
Startup groovysession1Startup groovysession1
Startup groovysession1
 
Django & Buildout (en)
Django & Buildout (en)Django & Buildout (en)
Django & Buildout (en)
 
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey BuzdinMarvel of Annotation Preprocessing in Java by Alexey Buzdin
Marvel of Annotation Preprocessing in Java by Alexey Buzdin
 
Detecting headless browsers
Detecting headless browsersDetecting headless browsers
Detecting headless browsers
 
Introduction to zc.buildout
Introduction to zc.buildoutIntroduction to zc.buildout
Introduction to zc.buildout
 
Gradle talk, Javarsovia 2010
Gradle talk, Javarsovia 2010Gradle talk, Javarsovia 2010
Gradle talk, Javarsovia 2010
 
Test your modules
Test your modulesTest your modules
Test your modules
 
Infrastructure as code - Python Saati #36
Infrastructure as code - Python Saati #36Infrastructure as code - Python Saati #36
Infrastructure as code - Python Saati #36
 
Testing JS with Jasmine
Testing JS with JasmineTesting JS with Jasmine
Testing JS with Jasmine
 
An intro to the JAMStack and Eleventy
An intro to the JAMStack and EleventyAn intro to the JAMStack and Eleventy
An intro to the JAMStack and Eleventy
 
PyCon Korea 2019 REST API Document Generation
PyCon Korea 2019 REST API Document GenerationPyCon Korea 2019 REST API Document Generation
PyCon Korea 2019 REST API Document Generation
 
Functional Reactive Programming on Android
Functional Reactive Programming on AndroidFunctional Reactive Programming on Android
Functional Reactive Programming on Android
 
Hands on the Gradle
Hands on the GradleHands on the Gradle
Hands on the Gradle
 
Testing of javacript
Testing of javacriptTesting of javacript
Testing of javacript
 
Zombiejs
ZombiejsZombiejs
Zombiejs
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
 
Asynchronous Module Definition (AMD)
Asynchronous Module Definition (AMD)Asynchronous Module Definition (AMD)
Asynchronous Module Definition (AMD)
 
groovy & grails - lecture 6
groovy & grails - lecture 6groovy & grails - lecture 6
groovy & grails - lecture 6
 
Like a Genie from a Lamp: Headless JavaScript Unit Testing with Jasmine and P...
Like a Genie from a Lamp: Headless JavaScript Unit Testing with Jasmine and P...Like a Genie from a Lamp: Headless JavaScript Unit Testing with Jasmine and P...
Like a Genie from a Lamp: Headless JavaScript Unit Testing with Jasmine and P...
 

Similar to Androidの本当にあった怖い話

JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
Kiyotaka Oku
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
Tomek Kaczanowski
 
Jersey framework
Jersey frameworkJersey framework
Jersey framework
knight1128
 
Codestrong 2012 breakout session hacking titanium
Codestrong 2012 breakout session   hacking titaniumCodestrong 2012 breakout session   hacking titanium
Codestrong 2012 breakout session hacking titanium
Axway Appcelerator
 

Similar to Androidの本当にあった怖い話 (20)

A topology of memory leaks on the JVM
A topology of memory leaks on the JVMA topology of memory leaks on the JVM
A topology of memory leaks on the JVM
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
 
2. Design patterns. part #2
2. Design patterns. part #22. Design patterns. part #2
2. Design patterns. part #2
 
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015
 
Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15
 
Jersey framework
Jersey frameworkJersey framework
Jersey framework
 
Xml & Java
Xml & JavaXml & Java
Xml & Java
 
Codestrong 2012 breakout session hacking titanium
Codestrong 2012 breakout session   hacking titaniumCodestrong 2012 breakout session   hacking titanium
Codestrong 2012 breakout session hacking titanium
 
New Features Of JDK 7
New Features Of JDK 7New Features Of JDK 7
New Features Of JDK 7
 
Java 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from OredevJava 7 Whats New(), Whats Next() from Oredev
Java 7 Whats New(), Whats Next() from Oredev
 
RxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камниRxJava и Android. Плюсы, минусы, подводные камни
RxJava и Android. Плюсы, минусы, подводные камни
 
Ejb3 Dan Hinojosa
Ejb3 Dan HinojosaEjb3 Dan Hinojosa
Ejb3 Dan Hinojosa
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on Android
 
Kotlin 1.2: Sharing code between platforms
Kotlin 1.2: Sharing code between platformsKotlin 1.2: Sharing code between platforms
Kotlin 1.2: Sharing code between platforms
 
Java
JavaJava
Java
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
 
Teste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrityTeste de Integração com DbUnit e jIntegrity
Teste de Integração com DbUnit e jIntegrity
 

More from Yusuke Yamamoto

WebStormから始まる快適Web開発ワークフロー #html5jk
WebStormから始まる快適Web開発ワークフロー #html5jkWebStormから始まる快適Web開発ワークフロー #html5jk
WebStormから始まる快適Web開発ワークフロー #html5jk
Yusuke Yamamoto
 
Troubleshooting Slowdowns, Freezes, Deadlocks : Introduction to Thread Dump #...
Troubleshooting Slowdowns, Freezes, Deadlocks : Introduction to Thread Dump #...Troubleshooting Slowdowns, Freezes, Deadlocks : Introduction to Thread Dump #...
Troubleshooting Slowdowns, Freezes, Deadlocks : Introduction to Thread Dump #...
Yusuke Yamamoto
 
Twitter API最新事情 - API Meetup Tokyo #1 #apijp
Twitter API最新事情 - API Meetup Tokyo #1 #apijpTwitter API最新事情 - API Meetup Tokyo #1 #apijp
Twitter API最新事情 - API Meetup Tokyo #1 #apijp
Yusuke Yamamoto
 
Java デバッガ活用術 ~勘デバッグ・print デバッグから抜けだそう~ #jjug_ccc #ccc_h4
Java デバッガ活用術 ~勘デバッグ・print デバッグから抜けだそう~ #jjug_ccc #ccc_h4Java デバッガ活用術 ~勘デバッグ・print デバッグから抜けだそう~ #jjug_ccc #ccc_h4
Java デバッガ活用術 ~勘デバッグ・print デバッグから抜けだそう~ #jjug_ccc #ccc_h4
Yusuke Yamamoto
 
貧乏人のHeroku活用術 #herokujp
貧乏人のHeroku活用術 #herokujp貧乏人のHeroku活用術 #herokujp
貧乏人のHeroku活用術 #herokujp
Yusuke Yamamoto
 
リーンスタートアップ x Java #jjug #jjug_ccc #ccc_h4
リーンスタートアップ x Java #jjug #jjug_ccc #ccc_h4リーンスタートアップ x Java #jjug #jjug_ccc #ccc_h4
リーンスタートアップ x Java #jjug #jjug_ccc #ccc_h4
Yusuke Yamamoto
 

More from Yusuke Yamamoto (20)

株式会社サムライズム 新製品発表会 物理イカリングのご紹介 #gbdaitokai
株式会社サムライズム 新製品発表会 物理イカリングのご紹介 #gbdaitokai株式会社サムライズム 新製品発表会 物理イカリングのご紹介 #gbdaitokai
株式会社サムライズム 新製品発表会 物理イカリングのご紹介 #gbdaitokai
 
これからはじめるGit、GitHub #stapy
これからはじめるGit、GitHub #stapyこれからはじめるGit、GitHub #stapy
これからはじめるGit、GitHub #stapy
 
誰も知らない IntelliJ IDEA凄技100選 #kotlin_sansan
誰も知らない IntelliJ IDEA凄技100選 #kotlin_sansan誰も知らない IntelliJ IDEA凄技100選 #kotlin_sansan
誰も知らない IntelliJ IDEA凄技100選 #kotlin_sansan
 
JetBrains IDEハンズオン
JetBrains IDEハンズオンJetBrains IDEハンズオン
JetBrains IDEハンズオン
 
Java Küche 2016 LT 在室状況自動通知ボット #JavaKueche
Java Küche 2016 LT 在室状況自動通知ボット #JavaKuecheJava Küche 2016 LT 在室状況自動通知ボット #JavaKueche
Java Küche 2016 LT 在室状況自動通知ボット #JavaKueche
 
Java Küche 2016 #JavaKueche
Java Küche 2016 #JavaKuecheJava Küche 2016 #JavaKueche
Java Küche 2016 #JavaKueche
 
JavaOne2016 #CON5929 Time-Saving Tips and Tricks for Building Quality Java Ap...
JavaOne2016 #CON5929 Time-Saving Tips and Tricks for Building Quality Java Ap...JavaOne2016 #CON5929 Time-Saving Tips and Tricks for Building Quality Java Ap...
JavaOne2016 #CON5929 Time-Saving Tips and Tricks for Building Quality Java Ap...
 
WebStormから始まる快適Web開発ワークフロー #html5jk
WebStormから始まる快適Web開発ワークフロー #html5jkWebStormから始まる快適Web開発ワークフロー #html5jk
WebStormから始まる快適Web開発ワークフロー #html5jk
 
データクラスから始めるKotlin / JetBrainsに行ってきました #kotlin_kansai #jkug
データクラスから始めるKotlin / JetBrainsに行ってきました #kotlin_kansai #jkug データクラスから始めるKotlin / JetBrainsに行ってきました #kotlin_kansai #jkug
データクラスから始めるKotlin / JetBrainsに行ってきました #kotlin_kansai #jkug
 
Troubleshooting Slowdowns, Freezes, Deadlocks : Introduction to Thread Dump #...
Troubleshooting Slowdowns, Freezes, Deadlocks : Introduction to Thread Dump #...Troubleshooting Slowdowns, Freezes, Deadlocks : Introduction to Thread Dump #...
Troubleshooting Slowdowns, Freezes, Deadlocks : Introduction to Thread Dump #...
 
カジュアルにスレッドダンプ - @yusuke #javacasual
カジュアルにスレッドダンプ - @yusuke #javacasualカジュアルにスレッドダンプ - @yusuke #javacasual
カジュアルにスレッドダンプ - @yusuke #javacasual
 
Excel方眼紙アプリケーションサーバと侍の新機能 #jjug
Excel方眼紙アプリケーションサーバと侍の新機能 #jjugExcel方眼紙アプリケーションサーバと侍の新機能 #jjug
Excel方眼紙アプリケーションサーバと侍の新機能 #jjug
 
Twitter4jハンズオン 5/1 #twtr_hack
Twitter4jハンズオン 5/1 #twtr_hackTwitter4jハンズオン 5/1 #twtr_hack
Twitter4jハンズオン 5/1 #twtr_hack
 
株式会社サムライズム@samuraismがcoincheck for ECを使ってビットコイン決済に対応した話 #gbdaitokai
株式会社サムライズム@samuraismがcoincheck for ECを使ってビットコイン決済に対応した話 #gbdaitokai 株式会社サムライズム@samuraismがcoincheck for ECを使ってビットコイン決済に対応した話 #gbdaitokai
株式会社サムライズム@samuraismがcoincheck for ECを使ってビットコイン決済に対応した話 #gbdaitokai
 
Botを使った業務効率化 / Java8を使ったBot実装効率化 @yusuke #jjug
Botを使った業務効率化 / Java8を使ったBot実装効率化 @yusuke #jjugBotを使った業務効率化 / Java8を使ったBot実装効率化 @yusuke #jjug
Botを使った業務効率化 / Java8を使ったBot実装効率化 @yusuke #jjug
 
Twitter API最新事情 - API Meetup Tokyo #1 #apijp
Twitter API最新事情 - API Meetup Tokyo #1 #apijpTwitter API最新事情 - API Meetup Tokyo #1 #apijp
Twitter API最新事情 - API Meetup Tokyo #1 #apijp
 
Java デバッガ活用術 ~勘デバッグ・print デバッグから抜けだそう~ #jjug_ccc #ccc_h4
Java デバッガ活用術 ~勘デバッグ・print デバッグから抜けだそう~ #jjug_ccc #ccc_h4Java デバッガ活用術 ~勘デバッグ・print デバッグから抜けだそう~ #jjug_ccc #ccc_h4
Java デバッガ活用術 ~勘デバッグ・print デバッグから抜けだそう~ #jjug_ccc #ccc_h4
 
貧乏人のHeroku活用術 #herokujp
貧乏人のHeroku活用術 #herokujp貧乏人のHeroku活用術 #herokujp
貧乏人のHeroku活用術 #herokujp
 
リーンスタートアップ x Java #jjug #jjug_ccc #ccc_h4
リーンスタートアップ x Java #jjug #jjug_ccc #ccc_h4リーンスタートアップ x Java #jjug #jjug_ccc #ccc_h4
リーンスタートアップ x Java #jjug #jjug_ccc #ccc_h4
 
JavaScript時代のJava #kansumiB7 #kansumi
JavaScript時代のJava #kansumiB7 #kansumiJavaScript時代のJava #kansumiB7 #kansumi
JavaScript時代のJava #kansumiB7 #kansumi
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 

Androidの本当にあった怖い話

  • 1. Android 2011/1/17 @yusukey Copyright(c) Yusuke Yamamoto All rights reserved.
  • 2. http://samuraism.jp/ @yusukey http://tinyurl.com/android-java Copyright(c) Yusuke Yamamoto All rights reserved.
  • 3. ↑ Java Twitter API • JDK1.4.2 • Google App Engine • Android Copyright(c) Yusuke Yamamoto All rights reserved.
  • 4. Android Java Copyright(c) Yusuke Yamamoto All rights reserved.
  • 5. Android Copyright(c) Yusuke Yamamoto All rights reserved.
  • 6. new sun.misc.BASE64Encoder().encode(buf); 02-20 18:03:59.843: WARN/dalvikvm(526): VFY: unable to resolve new-instance 105 (Lsun/misc/BASE64Encoder;) in Ltwitter4j/http/ HttpClient; 02-20 18:03:59.843: WARN/dalvikvm(526): VFY: rejecting opcode 0x22 at 0x0011 :Android sun.misc.* / com.sun.* Copyright(c) Yusuke Yamamoto All rights reserved.
  • 7. • BASE64 (Commons-Codec ok) • sun.misc.* com.sun.* Copyright(c) Yusuke Yamamoto All rights reserved.
  • 8. XML Copyright(c) Yusuke Yamamoto All rights reserved.
  • 9. XML • Twitter4J // XML private 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.
  • 10. 07-07 23:55:42.993: ERROR/dalvikvm(11182): Could not find method javax.xml.transform.TransformerFactory.newInstance, referenced from method twitter4j.TwitterResponse.toString :Android XSLT Copyright(c) Yusuke Yamamoto All rights reserved.
  • 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 “”; } } Copyright(c) Yusuke Yamamoto All rights reserved.
  • 12. 01-16 23:20:58.637: ERROR/AndroidRuntime(209): Uncaught handler: thread main exiting due to uncaught exception 01-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.
  • 13. -- // 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.
  • 14. XML 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()); Copyright(c) Yusuke Yamamoto All rights reserved.
  • 15. String xml = "<title>English &amp; </title>"; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance (); dbf.setCoalescing(true); dbf.setExpandEntityReferences(true); ByteArrayInputStream stream = new & : “English ByteArrayInputStream( ” xml.getBytes()); DocumentBuilder builder = “English” : 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.
  • 16. XML Copyright(c) Yusuke Yamamoto All rights reserved.
  • 17. • Twitter xml, JSON, atom, rss • JSON • JavaScript Object Notation • Web API Twitter4J JSON Copyright(c) Yusuke Yamamoto All rights reserved.
  • 18. JSON Copyright(c) Yusuke Yamamoto All rights reserved.
  • 19. JSON (“foo”:null, “longvalue”:”13857270119014401”} JSONObject json = new JSONObject ("{"foo":null,"longvalue":"13857270119014401"}"); // true System.out.println(json.isNull("foo")); // true System.out.println(null == json.getString("foo")); // false System.out.println("null".equals(json.getString("foo"))); // 13857270119014401 System.out.println(json.getLong("longvalue")); Copyright(c) Yusuke Yamamoto All rights reserved.
  • 20. JSONObject json = new JSONObject ("{"foo":null,"longvalue":"13857270119014401"}"); // true true System.out.println(json.isNull("foo")); // true true System.out.println(null == json.getString("foo")); // false true System.out.println("null".equals(json.getString("foo"))); // 13857270119014401 13857270119014400 System.out.println(json.getLong("longvalue")); :json Copyright(c) Yusuke Yamamoto All rights reserved.
  • 21. json.org twitter4j.internal.org.json.* Copyright(c) Yusuke Yamamoto All rights reserved.
  • 22. XSLT (Froyo ) • VerifyError • Eclair(Android 2.1) • XML • Froyo(Android 2.2) • JSON • • Sun Copyright(c) Yusuke Yamamoto All rights reserved.
  • 23. • Android public static final boolean IS_DALVIK; static{ try { // dalvik.system.VMRuntime class should be existing on Android 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.
  • 24. - Issue 2607 - android - org.apache.harmony.xml.parsers.DocumentBuilderImpl does not resolve unicode entity refs http://code.google.com/p/android/issues/detail?id=2607 - Issue 9244 - android - org.json packages out of date http://code.google.com/p/android/issues/detail?id=9244 - Issue 13830 - JSONObject.getString() returns "null" string literal for null value instead of null object. http://code.google.com/p/android/issues/detail?id=13830 - Issue 13831 - JSONObject.getLong() returns rounded and inaccurate value http://code.google.com/p/android/issues/detail?id=13831 Copyright(c) Yusuke Yamamoto All rights reserved.