wtk partial code description jin tae kum hpcc lab sookmyung women ’ s university

22
WTK partial code description Jin Tae Kum HPCC lab Sookmyung Women’s Univers ity

Upload: arleen-hunt

Post on 02-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

WTK partial code description

Jin Tae Kum HPCC lab

Sookmyung Women’s University

C:\WTK21\bin>emulator -helpfile IO Exception:java.util.zip.ZipException: invalid EXT descriptor signatureSyntax:

emulator [arguments] <Application>

Arguments are:

-classpath, -cp The class path for the VM-D<property=value> Property definitions-version Display version information about the emulator-help Display list of valid arguments-Xverbose[: allocation | gc | gcverbose | class | classverbose | verifier | stackmaps | bytecodes | calls | callsverbose | frames | stackchunks | exceptions | events | threading | monitors | networking | all enable verbose output-Xquery Query options-Xdebug Use a remote debugger

Emulator options

-Xrunjdwp:[transport=<transport>,address=<address>,server=<y/n> suspend=<y/n>] Debugging options-Xdevice:<device name> Name of the device to be emulated-Xdescriptor:<jad file name> The JAD file to be executed-Xjam[:install=<jad file url> | force | list | storageNames | run=[<storage name> | <storage number>] | remove=[<storage name> | <storage number> | all] | transient=<jad file url>] Java Application Manager and support for Over The Air provisioning (OTA)-Xheapsize:<size> (e.g. 65536 or 128k or 1M) specifies the VM heapsize (overrides default value)-Xprefs:<filename> Override preferences by properties in file-Xnoagent Supported for backwards compatibility-Xdomain:<domain_name> Set the MIDlet suite's security domain

Emulator options

main() in EmulatorWrapper.javapublic static void main(String args[]) throws UnsupportedEncodingException { String s = ToolkitDirs.USER_HOME + "wtklib" + File.separator + "runtime.properties"; Debug.mergeSystemProperties(new File(s)); *****#### runtime.properties 없음 ***** 임시적 생성 .. directory 에 없음 String s1 = ToolkitDirs.LIB + "runtime.properties"; Debug.mergeSystemProperties(new File(s1));

>>>>>>>>>>>>>>>>>insert here~~~ Debug.mergeSystemProperties public static void mergeSystemProperties(File file) throws IOException { FileInputStream fileinputstream = new FileInputStream(file); Properties properties = new Properties(); properties.load(fileinputstream); *************runtime.properties 안의 내용을 로드 Enumeration enumeration = properties.keys(); Properties properties1 = System.getProperties(); ***** 시스템에서 가져온 프로퍼티 집합 String s; String s1; for(; enumeration.hasMoreElements(); properties1.setProperty(s, s1.trim())) { s = (String)enumeration.nextElement(); ****** runtime.properties 의 프로퍼티 키 s1 = properties.getProperty(s); ********** runtime.properties 의 value }

fileinputstream.close(); makeLogWriter(); showCurrentTime = Boolean.getBoolean("debug.showTime"); }<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<end insert~~~

main() in EmulatorWrapper.java …Continued debug = Debug.create(com.sun.kvem.environment.EmulatorWrapper.class); KeepAliveConnection keepaliveconnection = new KeepAliveConnection(); args = keepaliveconnection.processArgv(args); => port 번호만 keepaliveconnection 에 넘겨줌 , 나머지 다시 받음 keepaliveconnection.setCallback(KeepAliveConnection.CALLBACK_EXIT); keepaliveconnection.run(); … 중략 debug.println(1, "Running EmulatorWrapper, argv = {0}", args); EmulatorWrapper emulatorwrapper = new EmulatorWrapper(); ……… 중략 args = StringArrayUtils.subarray(args, 1); i = emulatorwrapper.run(args);

>>>>>>>>>>>>> run 의 리턴값… 정상 종료하기 위해선 0 을 리턴해야 함 , exception 발생시 1 리턴 i 리턴 .. 출력 후 ... System.exit(i); 0 리턴 시 flush.. initial setting...

>>>>>>>>>>>> run()public int run(String as[]) ### as: 명령어 라인 인수들의 집합 ( 스트링 어레이 ) ### s,s1,s2...: 각각의 명령어 옵션 ### flag1,2,3...: enable, disable 여부각각의 인수에 대한 처리를 함 .

WTK21\wtklib\kenv\com\sun\kvem\environment\EmulatorWrapper.java

EmulatorWrapper

main(String as[])

run(String as[])

KeepAliveConnection keepaliveconnection = new KeepAliveConnection();

args = keepaliveconnection.processArgv(args);

keepaliveconnection.run();

EmulatorWrapper emulatorwrapper = new EmulatorWrapper();

i = emulatorwrapper.run(args);

KeepAliveConnection

processArgv(String as[])

run()

EmulatorWrapper

main(String as[])

run()

kac.processArgv(args)

kac.run();

WTK21\wtklib\kenv\com\sun\kvem\environment\KeepAliveConnetion.java

KeepAliveConnectionprocessArgv(String as[])

run(String as[])

port = Integer.parseInt(as[as.length - 1]);

as1 = array as 에서 port 를 제외한 부분return as1;

port != 0

(new Thread(new Communicator())).start();

class Communicator

run()Socket socket = new Socket(inetaddress, port);

if(s5.startsWith("-Xverbose:")) { String s7 = s5.substring("-Xverbose:".length()); for(StringTokenizer stringtokenizer = new StringTokenizer(s7, ",") ; stringtokenizer.hasMoreTokens();) { String s22 = stringtokenizer.nextToken(); //s22 : sub option try // ex: calls, class, allocation {

tracingoptions.setTrace(s22, true); } catch(IllegalArgumentException illegalargumentexception) { String s28 = "\"" + s22 + "\"" + " is not a valid option for -Xverbose"; throw new SyntaxException(s28); } }

continue; }

Solving option in EmulatorWrapper.java

public class TracingOptions :import java.lang.reflect.Method; import java.util.*;

// Referenced classes of package com.sun.kvem.environment:// Debug, PropertiesFile, ProfileConfiguration

DSMethod amethod[] = (com.sun.kvem.environment.ProfileConfiguration.class).getMethods();arraylist = optionList = smallOptionList( 소문자 ) arraylist : setTrace 가 available 한 option 들의 집합

Methodpublic void setTrace(String s, boolean flag) //* setting to selectedOption if s is in (available optionList)public void setTraceConfiguration(ProfileConfiguration profileconfiguration){ Class class1 = profileconfiguration.getClass(); … 중략 String s = "setTrace" + optionList[i]; Method method = class1.getMethod(s, aclass); aclass <= Boolean.TYPE //* s 라는 이름의 parameter type 이 boolean 인 함수 method.invoke(profileconfiguration, aobj); //* 해당 profileconfiguration 과 true(enable) 값을 넘겨줌 .. aobj <= Boolean.TRUE … 생략 … . }

(Continued in class TracingOptions)

Method private String getPropertyKey(String s) { //* s: trace 의 하위옵션 .. 무엇을 trace 할 것인가 .. //….. 중략… Field field = (com.sun.kvem.environment.ProfileConfiguration.class).getField(s1); return (String)field.get(null); //* s1:trace option 의 full name(TRACE_ 라는 prefix 붙음 ) 을 넘겨줌 // 이하 생략 }

public void setFromProperties(PropertiesFile propertiesfile){ … 중략… String s = optionList[i]; *** s : setTrace 대상 String s1 = getPropertyKey(s); *** s1: 해당 키값 String s2 = propertiesfile.getProperty(s1); ***s2: 키에 대한 프로퍼티 값가져오기 boolean flag = "true".equalsIgnoreCase(s2); *** flag: 프로퍼티 값이 참이면 setTrace(smallOptionList[i], flag); *** 해당옵션에 대한 setTrace 호출 …. 이하 생략… }

Set Configuration in EmulatorWrapper.java

• Call initializeConfiguration

final ProfileEnvironment env = new ProfileEnvironment(); ProfileConfiguration profileconfiguration = (ProfileConfiguration)env.createConfiguration(); try { initializeConfiguration(profileconfiguration, file); ## Configuration based on input preferences file env.setCmdLineProperties(file);

private void initializeConfiguration(ProfileConfiguration profileconfiguration, File file) throws IOException { try { preferences = new PropertiesFile(new File(DEFAULT_PREFS_LOC)); ## create empty file if(file != null) { PropertiesFile propertiesfile = new PropertiesFile(file); ## create based on file (file: preference file given from prompt) preferences.setPropertiesList(propertiesfile.getPropertiesList()); ## copy } TracingOptions tracingoptions = new TracingOptions(); tracingoptions.setFromProperties(preferences); ## 넘겨줌 tracingoptions.setTraceConfiguration(profileconfiguration); String s = preferences.getProperty("heap.size"); if(s != null) profileconfiguration.setHeapSize(s); String s2 = preferences.getProperty("http.proxyHost");

Set Configuration in EmulatorWrapper.java

if(s2 != null && !s2.equals("")) { System.setProperty("http.proxyHost", s2); String s3 = preferences.getProperty("http.proxyPort"); if(s3 != null && !s3.equals("")) { System.setProperty("http.proxyPort", s3); ## set To System profileconfiguration.setHttpProxy(s2 + ":" + s3); ## set ProfileConfiguration } else { System.setProperty("http.proxyPort", null); profileconfiguration.setHttpProxy(s2); } } String s4 = preferences.getProperty("https.proxyHost"); if(s4 != null && !s4.equals("")) { String s5 = preferences.getProperty("https.proxyPort"); if(s5 != null && !s5.equals("")) profileconfiguration.setHttpsProxy(s4 + ":" + s5); else profileconfiguration.setHttpsProxy(s4); } }}

Continued..

PofileConfiguration :Set of Property objects (Trace 관련 옵션 포함 )Property object: each entry in emulator.poperties

TracingOptions : invoke profileconfiguration

By (method.invoke(profileconfiguration, aobj)ProfileConfiguration 에 따라 trace 활성화

EmulatorWrapper : receives args(opt) from prompt

initiateinitiate

Calls to set

ProfileEnvironment.java• Run()

– New File(ToolkitDirs.LIB, “emulator.properties”) 파일 생성후 그 파일의 propertylist 와 configuration property 를 getPropertiesList() 와 getconfiguration Properties(c) 메소드를 통해 정보를 저장한다 .

– runEmulator() 호출

• runEmulator(Properties p, String as[])– 에뮬레이터를 실행시킬 새로운 EmulatorInvoker 를 생성하고

그 Invoker 를 통해 저장한 property 정보를 넘겨주면서 에뮬레이터를 실행

– getEmulatorClass();– New Emulatorinvoker();

• EmulatorWrapper.java 내에서 ProfileEnvironment.Start(profileconfiguration, as5) 호출

• ProfileEnvironment 소스내에서 start() 호출– Static void start(EmulatorConfiguration emulatorconfiguration,

String as[]) 호출 – Runner.start(emulatorconfiguration, as);

• getEmulatorThread(), – verifyVMVersion(): 자바 버전체크 – setproperty(lime.loader, KWAPPER_Path) – KVMTHread()

• isSynchronouMode() 호출

Appendix. Configuration file in wtk directory

# Properties visible from System.getProperty()microedition.jtwi.version: 1.0microedition.configuration: CLDC-1.1microedition.profiles: MIDP-2.0microedition.locale: en-USmicroedition.platform: j2me# microedition.encoding: ISO8859_1microedition.commports: 0,1## I18N aliases for common character encodingsSHIFT_JIS_InternalEncodingName: SJISX_SJIS_InternalEncodingName: SJIS## CLDC implementation parameters

# use MIDP protocol implementationsjavax.microedition.io.Connector.protocolpath: com.sun.kvem.io

# java.lang.Character.caseConverter: com.sun.cldc.i18n.uclc.DefaultCaseConverter# com.sun.cldc.i18n.Helper.i18npath: com.sun.cldc.i18n.j2me# microedition.implpath: com.sun.cldc# com.sun.cldc.util.j2me.TimeZoneImpl.timezone: UTC

# WMAwireless.messaging.sms.smsc : +12345678900

# MMAPI public propertiesmicroedition.media.version: 1.1supports.audio.capture: trueaudio.encodings: encoding=pcmstreamable.contents: audio/x-wav

wtk21/lib/System.config

# Visible from com.sun.midp.Configuration.getProperty(key)## System tunable parameters (system prefix indicates native only access)#system.jam_space: 1000000system.display.double_buffered:truesystem.display.screen_depth: 8system.i18n.lang: ensystem.i18n.encoding: ISO8859_1# system.display.debug_screen: # system.display.visual_type: TrueColor# system.display.kh_skins: TrueColor# com.sun.midp.io.j2me.comm.buffersize: 256# com.sun.midp.io.j2me.socket.buffersize: 256#com.sun.midp.midlet.scheduler: com.sun.midp.midlet.Scheduler#com.sun.midp.lcdui.eventHandler: com.sun.midp.lcdui.DefaultEventHandler# For J2SE# com.sun.midp.lcdui.eventHandler: com.sun.midp.lcdui.AWTEventHandler#com.sun.midp.lcdui.inputHandler: com.sun.midp.lcdui.DefaultInputMethodHandler# com.sun.midp.midletsuite.installer: com.sun.midp.midletsuite.Installer# com.sun.midp.midletsuite.installer: com.sun.midp.midletsuite.SecureInstaller# com.sun.midp.graphicalmanager: com.sun.midp.dev.Manager# com.sun.midp.lcdui.skin: classes/icons/skin.gif#com.sun.midp.io.http.proxy: webcache:8080#com.sun.midp.io.http.force_non_persistent: false#com.sun.midp.io.http.persistent_connection_linger_time: 60000#com.sun.midp.io.http.input_buffer_size: 256#com.sun.midp.io.http.output_buffer_size: 2048

wtk21/lib/internal.config

com.sun.midp.io.http.max_persistent_connections: 4#### Default values for SMS internal implementation.com.sun.midp.io.j2me.sms.DatagramHost: localhost## Alternate SMS port for CBS emulationcom.sun.midp.io.j2me.sms.CBSPort: 24680# Sender's phone numbercom.sun.midp.io.j2me.sms.PhoneNumber=+5551212# Default SMS Sercice Center addresswireless.messaging.sms.smsc: +17815511212

# This file is appended at the end of the MIDP internal.config file.

com.sun.midp.io.enable_extra_protocols: truecom.sun.midp.io.http.use_chunks: true

wtk21/lib/internal.config

file.extension: jadheap.size: http.proxyHost: http.proxyPort: http.version: HTTP/1.1https.proxyHost: https.proxyPort: jammode: kvem.api.exclude: kvem.device: DefaultColorPhonekvem.memory.monitor.enable: truekvem.netmon.autoclose: falsekvem.netmon.enable: falsekvem.netmon.filter_file_name: netmon_filter.datkvem.netmon.fixed_font_name: Courier Newkvem.netmon.fixed_font_size: 12kvem.profiler.enable: falsekvem.profiler.outfile: kvem.profiler.showsystem: falsekvem.trace.all: falsekvem.trace.allocation: falsekvem.trace.bytecodes: falsekvem.trace.calls: falsekvem.trace.calls.verbose: falsekvem.trace.class: falsekvem.trace.class.verbose: falsekvem.trace.events: falsekvem.trace.exceptions: falsekvem.trace.frames: falsekvem.trace.gc: falsekvem.trace.gc.verbose: false

kvem.trace.monitors: falsekvem.trace.networking: falsekvem.trace.stackchunks: falsekvem.trace.stackmaps: falsekvem.trace.threading: falsekvem.trace.verifier: falsemm.control.capture: truemm.control.midi: truemm.control.mixing: truemm.control.record: truemm.control.volume: truemm.format.midi: truemm.format.video: truemm.format.wav: truenetspeed.bitpersecond: 1200netspeed.enableSpeedEmulation: falseprng.secure: falsescreen.graphicsLatency: 0screen.refresh.mode: screen.refresh.rate: 30security.domain: untrustedstorage.root: storage.size: vmspeed.bytecodespermilli: 10vmspeed.enableEmulation: falsewma.client.phoneNumber: wma.server.deliveryDelayMS: wma.server.firstAssignedPhoneNumber: +5550000wma.server.percentFragmentLoss: 0wma.smsc.phoneNumber: +1234567890

wtk21/wtklib/Emulator.properties

# @(#)ktools.properties 1.7 03/08/07

kjava.preverifier.command: bin\\preverify.exekjava.class.path: lib\\midpapi20.zip;lib\\cldcapi10.zipfile.extension: jadobfuscator.runner.class.name: com.sun.kvem.ktools.RunProobfuscator.runner.classpath: wtklib\\ktools.zipobfuscate.script.name:

wtk21/wtklib/Windows/ktools.properties