1 /******************************************************************************* 2 * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors 3 * This program and the accompanying materials are made available under 4 * the terms of the Eclipse Public License 2.0 which is available at 5 * http://www.eclipse.org/legal/epl-2.0 6 * 7 * SPDX-License-Identifier: EPL-2.0 8 * 9 * Contributors: 10 * Marc R. Hoffmann - initial API and implementation 11 * 12 *******************************************************************************/ 13 package org.jacoco.core.runtime; 14 15 import java.util.Random; 16 17 /** 18 * Base {@link IRuntime} implementation. 19 */ 20 public abstract class AbstractRuntime implements IRuntime { 21 22 /** access to the runtime data */ 23 protected RuntimeData data; 24 25 /** 26 * Subclasses must call this method when overwriting it. 27 */ startup(final RuntimeData data)28 public void startup(final RuntimeData data) throws Exception { 29 this.data = data; 30 } 31 32 private static final Random RANDOM = new Random(); 33 34 /** 35 * Creates a random session identifier. 36 * 37 * @return random session identifier 38 */ createRandomId()39 public static String createRandomId() { 40 return Integer.toHexString(RANDOM.nextInt()); 41 } 42 43 } 44