11package com .tns ;
22
33import java .io .File ;
4-
54import org .json .JSONObject ;
6-
75import android .os .Build ;
86import android .util .Log ;
97
108class AppConfig {
11- private enum KnownKeys {
9+ protected enum KnownKeys {
1210 V8FlagsKey ("v8Flags" , "--expose_gc" ),
1311 CodeCacheKey ("codeCache" , false ),
1412 HeapSnapshotScriptKey ("heapSnapshotScript" , "" ),
@@ -18,7 +16,7 @@ private enum KnownKeys {
1816 MemoryCheckInterval ("memoryCheckInterval" , 0 ),
1917 FreeMemoryRatio ("freeMemoryRatio" , 0.0 ),
2018 Profiling ("profiling" , "" ),
21- MarkingMode ("markingMode" , com .tns .MarkingMode .values ()[ 0 ] );
19+ MarkingMode ("markingMode" , com .tns .MarkingMode .full );
2220
2321 private final String name ;
2422 private final Object defaultValue ;
@@ -52,7 +50,7 @@ public AppConfig(File appDir) {
5250 try {
5351 rootObject = FileSystem .readJSONFile (packageInfo );
5452 if (rootObject != null ) {
55- if (rootObject .has (KnownKeys .Profiling .name ())) {
53+ if (rootObject .has (KnownKeys .Profiling .getName ())) {
5654 String profiling = rootObject .getString (KnownKeys .Profiling .getName ());
5755 values [KnownKeys .Profiling .ordinal ()] = profiling ;
5856 }
@@ -92,9 +90,12 @@ public AppConfig(File appDir) {
9290 }
9391 if (androidObject .has (KnownKeys .MarkingMode .getName ())) {
9492 try {
95- String value = androidObject .getString (KnownKeys .MarkingMode .getName ());
96- values [KnownKeys .MarkingMode .ordinal ()] = MarkingMode .valueOf (value );
97- } catch (Throwable e ) {
93+ String markingModeString = androidObject .getString (KnownKeys .MarkingMode .getName ());
94+ MarkingMode markingMode = MarkingMode .valueOf (markingModeString );
95+ values [KnownKeys .MarkingMode .ordinal ()] = markingMode ;
96+ } catch (Exception e ) {
97+ e .printStackTrace ();
98+ Log .v ("JS" , "Failed to parse marking mode. The default " + ((MarkingMode )KnownKeys .MarkingMode .getDefaultValue ()).name () + " will be used." );
9899 }
99100 }
100101 }
@@ -131,5 +132,6 @@ public double getFreeMemoryRatio() {
131132 public String getProfilingMode () {
132133 return (String )values [KnownKeys .Profiling .ordinal ()];
133134 }
135+
134136 public MarkingMode getMarkingMode () { return (MarkingMode )values [KnownKeys .MarkingMode .ordinal ()]; }
135137}
0 commit comments