1 /* 2 * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 package gc.g1.unloading.configuration; 24 25 /** 26 * Configuration object encapsulates test configuration. 27 */ 28 public class TestConfiguration { 29 30 private ReleaseRefMode releaseRefMode = ReleaseRefMode.NONE; 31 32 private WhatToKeep whatToKeep = WhatToKeep.CLASS; 33 34 private ClassloadingMethod classloadingMethod = ClassloadingMethod.REFLECTION; 35 36 private KeepRefMode keepRefMode = KeepRefMode.STRONG_REFERENCE; 37 38 private boolean humongousClass = false; 39 40 private int compilationLevel = 0; 41 42 private int compilationNumber = 2; 43 44 private boolean redefineClasses = false; 45 46 private boolean inMemoryCompilation = false; 47 48 public ReleaseRefMode getReleaseRefMode() { 49 return releaseRefMode; 50 } 51 52 public WhatToKeep getWhatToKeep() { 53 return whatToKeep; 54 } 55 56 public ClassloadingMethod getClassloadingMethod() { 57 return classloadingMethod; 58 } 59 60 public KeepRefMode getKeepRefMode() { 61 return keepRefMode; 62 } 63 64 public boolean isHumongousClass() { 65 return humongousClass; 66 } 67 68 public int getCompilationLevel() { 69 return compilationLevel; 70 } 71 72 public int getCompilationNumber() { 73 return compilationNumber; 74 } 75 76 public boolean isRedefineClasses() { 77 return redefineClasses; 78 } 79 80 public boolean isInMemoryCompilation() { 81 return inMemoryCompilation; 82 } 83 84 public int getNumberOfGCsBeforeCheck() { 85 return numberOfGCsBeforeCheck; 86 } 87 88 public int getNumberOfChecksLimit() { 89 return numberOfChecksLimit; 90 } 91 92 private int numberOfGCsBeforeCheck = 50; 93 94 private int numberOfChecksLimit = -1; 95 96 public static TestConfiguration createTestConfiguration(String[] args) { 97 TestConfiguration c = new TestConfiguration(); 98 for (int i = 0; i < args.length; i++) { 99 if ("-referenceMode".equalsIgnoreCase(args[i])) { 100 c.releaseRefMode = ReleaseRefMode.valueOf(args[i + 1].toUpperCase()); 101 } else if ("-numberOfGCsBeforeCheck".equalsIgnoreCase(args[i])) { 102 c.numberOfGCsBeforeCheck = Integer.valueOf(args[i + 1].toUpperCase()); 103 } else if ("-keep".equalsIgnoreCase(args[i])) { 104 c.whatToKeep = WhatToKeep.valueOf(args[i + 1].toUpperCase()); 105 } else if ("-classloadingMethod".equalsIgnoreCase(args[i])) { 106 c.classloadingMethod = ClassloadingMethod.valueOf(args[ i + 1].toUpperCase()); 107 } else if ("-keepRefMode".equalsIgnoreCase(args[i])) { 108 c.keepRefMode = KeepRefMode.valueOf(args[i + 1]); 109 } else if ("-humongousClass".equalsIgnoreCase(args[i])) { 110 c.humongousClass = "true".equals(args[i + 1]); 111 } else if ("-compilationLevel".equalsIgnoreCase(args[i])) { 112 c.compilationLevel = Integer.valueOf(args[i + 1]); 113 } else if ("-compilationNumber".equalsIgnoreCase(args[i])) { 114 c.compilationNumber = Integer.valueOf(args[i + 1]); 115 } else if ("-redefineClasses".equalsIgnoreCase(args[i])) { 116 c.redefineClasses = "true".equals(args[i + 1]); 117 } else if ("-inMemoryCompilation".equalsIgnoreCase(args[i])) { 118 c.inMemoryCompilation = "true".equals(args[i + 1]); 119 } else if ("-numberOfChecksLimit".equalsIgnoreCase(args[i])) { 120 c.numberOfChecksLimit = Integer.parseInt(args[i + 1]); 121 } else if (args[i].startsWith("-") && ! "-stressTime".equals(args[i])) { 122 System.out.println("\n\nWarning!! Unrecognized option " + args[i] + "\n\n"); 123 } 124 } 125 System.out.println("releaseRefMode = " + c.releaseRefMode); 126 System.out.println("whatToKeep = " + c.whatToKeep); 127 System.out.println("classlodingMethod = " + c.classloadingMethod); 128 System.out.println("numberOfGCsBeforeCheck = " + c.numberOfGCsBeforeCheck); 129 System.out.println("keepRefMode = " + c.keepRefMode); 130 System.out.println("humongousClass = " + c.humongousClass); 131 System.out.println("compilationLevel = " + c.compilationLevel); 132 System.out.println("compilationNumber = " + c.compilationNumber); 133 System.out.println("redefineClasses = " + c.redefineClasses); 134 System.out.println("inMemoryCompilation = " + c.inMemoryCompilation); 135 System.out.println("numberOfChecksLimit = " + c.numberOfChecksLimit); 136 return c; 137 } 138 139 }