@Test public void mustFailIfDebugTypeIncorrect() throws Exception { Instrumentation inst = mock(Instrumentation.class); String agentArgs = "markerType=NONE,debugType=ffffffffffff"; assertThrows(IllegalArgumentException.class, () -> { CoroutinesAgent.premain(agentArgs, inst); }); }
public static void premain(String agentArgs, Instrumentation inst) { MarkerType markerType = MarkerType.NONE; boolean debugMode = false; boolean autoSerializable = true; if (agentArgs != null && !agentArgs.isEmpty()) { String[] splitArgs = agentArgs.split(","); for (String splitArg : splitArgs) { String[] keyVal = splitArg.split("=", 2); if (keyVal.length != 2) { throw new IllegalArgumentException("Unrecognized arg passed to Coroutines Java agent: " + splitArg); } String key = keyVal[0]; String val = keyVal[1]; switch (key) { case "markerType": try { markerType = MarkerType.valueOf(val); } catch (IllegalArgumentException iae) { throw new IllegalArgumentException("Unable to parse marker type -- must be one of the following: " + Arrays.toString(MarkerType.values()), iae); } break; case "debugMode": if (val.equalsIgnoreCase("true")) { debugMode = true; } else if (val.equalsIgnoreCase("false")) { debugMode = false; } else { throw new IllegalArgumentException("Unable to parse debug mode -- must be true or false"); } break; case "autoSerializable": if (val.equalsIgnoreCase("true")) { autoSerializable = true; } else if (val.equalsIgnoreCase("false")) { autoSerializable = false; } else { throw new IllegalArgumentException("Unable to parse debug mode -- must be true or false"); } break; default: throw new IllegalArgumentException("Unrecognized arg passed to Coroutines Java agent: " + keyVal); } } } inst.addTransformer(new CoroutinesClassFileTransformer(markerType, debugMode, autoSerializable)); }
CoroutinesAgent { public static void premain(String agentArgs, Instrumentation inst) { MarkerType markerType = MarkerType.NONE; boolean debugMode = false; boolean autoSerializable = true; if (agentArgs != null && !agentArgs.isEmpty()) { String[] splitArgs = agentArgs.split(","); for (String splitArg : splitArgs) { String[] keyVal = splitArg.split("=", 2); if (keyVal.length != 2) { throw new IllegalArgumentException("Unrecognized arg passed to Coroutines Java agent: " + splitArg); } String key = keyVal[0]; String val = keyVal[1]; switch (key) { case "markerType": try { markerType = MarkerType.valueOf(val); } catch (IllegalArgumentException iae) { throw new IllegalArgumentException("Unable to parse marker type -- must be one of the following: " + Arrays.toString(MarkerType.values()), iae); } break; case "debugMode": if (val.equalsIgnoreCase("true")) { debugMode = true; } else if (val.equalsIgnoreCase("false")) { debugMode = false; } else { throw new IllegalArgumentException("Unable to parse debug mode -- must be true or false"); } break; case "autoSerializable": if (val.equalsIgnoreCase("true")) { autoSerializable = true; } else if (val.equalsIgnoreCase("false")) { autoSerializable = false; } else { throw new IllegalArgumentException("Unable to parse debug mode -- must be true or false"); } break; default: throw new IllegalArgumentException("Unrecognized arg passed to Coroutines Java agent: " + keyVal); } } } inst.addTransformer(new CoroutinesClassFileTransformer(markerType, debugMode, autoSerializable)); } }
CoroutinesAgent { public static void premain(String agentArgs, Instrumentation inst) { MarkerType markerType = MarkerType.NONE; boolean debugMode = false; boolean autoSerializable = true; if (agentArgs != null && !agentArgs.isEmpty()) { String[] splitArgs = agentArgs.split(","); for (String splitArg : splitArgs) { String[] keyVal = splitArg.split("=", 2); if (keyVal.length != 2) { throw new IllegalArgumentException("Unrecognized arg passed to Coroutines Java agent: " + splitArg); } String key = keyVal[0]; String val = keyVal[1]; switch (key) { case "markerType": try { markerType = MarkerType.valueOf(val); } catch (IllegalArgumentException iae) { throw new IllegalArgumentException("Unable to parse marker type -- must be one of the following: " + Arrays.toString(MarkerType.values()), iae); } break; case "debugMode": if (val.equalsIgnoreCase("true")) { debugMode = true; } else if (val.equalsIgnoreCase("false")) { debugMode = false; } else { throw new IllegalArgumentException("Unable to parse debug mode -- must be true or false"); } break; case "autoSerializable": if (val.equalsIgnoreCase("true")) { autoSerializable = true; } else if (val.equalsIgnoreCase("false")) { autoSerializable = false; } else { throw new IllegalArgumentException("Unable to parse debug mode -- must be true or false"); } break; default: throw new IllegalArgumentException("Unrecognized arg passed to Coroutines Java agent: " + keyVal); } } } inst.addTransformer(new CoroutinesClassFileTransformer(markerType, debugMode, autoSerializable)); } private  CoroutinesAgent(); }
CoroutinesAgent { public static void premain(String agentArgs, Instrumentation inst) { MarkerType markerType = MarkerType.NONE; boolean debugMode = false; boolean autoSerializable = true; if (agentArgs != null && !agentArgs.isEmpty()) { String[] splitArgs = agentArgs.split(","); for (String splitArg : splitArgs) { String[] keyVal = splitArg.split("=", 2); if (keyVal.length != 2) { throw new IllegalArgumentException("Unrecognized arg passed to Coroutines Java agent: " + splitArg); } String key = keyVal[0]; String val = keyVal[1]; switch (key) { case "markerType": try { markerType = MarkerType.valueOf(val); } catch (IllegalArgumentException iae) { throw new IllegalArgumentException("Unable to parse marker type -- must be one of the following: " + Arrays.toString(MarkerType.values()), iae); } break; case "debugMode": if (val.equalsIgnoreCase("true")) { debugMode = true; } else if (val.equalsIgnoreCase("false")) { debugMode = false; } else { throw new IllegalArgumentException("Unable to parse debug mode -- must be true or false"); } break; case "autoSerializable": if (val.equalsIgnoreCase("true")) { autoSerializable = true; } else if (val.equalsIgnoreCase("false")) { autoSerializable = false; } else { throw new IllegalArgumentException("Unable to parse debug mode -- must be true or false"); } break; default: throw new IllegalArgumentException("Unrecognized arg passed to Coroutines Java agent: " + keyVal); } } } inst.addTransformer(new CoroutinesClassFileTransformer(markerType, debugMode, autoSerializable)); } private  CoroutinesAgent(); static void premain(String agentArgs, Instrumentation inst); }
CoroutinesAgent { public static void premain(String agentArgs, Instrumentation inst) { MarkerType markerType = MarkerType.NONE; boolean debugMode = false; boolean autoSerializable = true; if (agentArgs != null && !agentArgs.isEmpty()) { String[] splitArgs = agentArgs.split(","); for (String splitArg : splitArgs) { String[] keyVal = splitArg.split("=", 2); if (keyVal.length != 2) { throw new IllegalArgumentException("Unrecognized arg passed to Coroutines Java agent: " + splitArg); } String key = keyVal[0]; String val = keyVal[1]; switch (key) { case "markerType": try { markerType = MarkerType.valueOf(val); } catch (IllegalArgumentException iae) { throw new IllegalArgumentException("Unable to parse marker type -- must be one of the following: " + Arrays.toString(MarkerType.values()), iae); } break; case "debugMode": if (val.equalsIgnoreCase("true")) { debugMode = true; } else if (val.equalsIgnoreCase("false")) { debugMode = false; } else { throw new IllegalArgumentException("Unable to parse debug mode -- must be true or false"); } break; case "autoSerializable": if (val.equalsIgnoreCase("true")) { autoSerializable = true; } else if (val.equalsIgnoreCase("false")) { autoSerializable = false; } else { throw new IllegalArgumentException("Unable to parse debug mode -- must be true or false"); } break; default: throw new IllegalArgumentException("Unrecognized arg passed to Coroutines Java agent: " + keyVal); } } } inst.addTransformer(new CoroutinesClassFileTransformer(markerType, debugMode, autoSerializable)); } private  CoroutinesAgent(); static void premain(String agentArgs, Instrumentation inst);  }