List of usage examples for java.lang Long longValue
@HotSpotIntrinsicCandidate public long longValue()
From source file:de.unisb.cs.st.javaslicer.slicing.Slicer.java
public static void main(String[] args) throws InterruptedException { Options options = createOptions();//from ww w. ja v a2s . com CommandLineParser parser = new GnuParser(); CommandLine cmdLine; try { cmdLine = parser.parse(options, args, true); } catch (ParseException e) { System.err.println("Error parsing the command line arguments: " + e.getMessage()); return; } if (cmdLine.hasOption('h')) { printHelp(options, System.out); System.exit(0); } String[] additionalArgs = cmdLine.getArgs(); if (additionalArgs.length != 2) { printHelp(options, System.err); System.exit(-1); } // ?? 1. ? 2.? File traceFile = new File(additionalArgs[0]); String slicingCriterionString = additionalArgs[1]; Long threadId = null; if (cmdLine.hasOption('t')) { // the interesting thread id for slicing try { threadId = Long.parseLong(cmdLine.getOptionValue('t')); } catch (NumberFormatException e) { System.err.println("Illegal thread id: " + cmdLine.getOptionValue('t')); System.exit(-1); } } TraceResult trace; try { trace = TraceResult.readFrom(traceFile); } catch (IOException e) { System.err.format("Could not read the trace file \"%s\": %s%n", traceFile, e); System.exit(-1); return; } List<SlicingCriterion> sc = null; // a list contains the instruction's info corresponds to the slicing criterion //slicingCriterionString get from additionalArgs[1] try { sc = StaticSlicingCriterion.parseAll(slicingCriterionString, trace.getReadClasses()); } catch (IllegalArgumentException e) { System.err.println("Error parsing slicing criterion: " + e.getMessage()); System.exit(-1); return; } List<ThreadId> threads = trace.getThreads(); // the threads that generate the traces if (threads.size() == 0) { System.err.println("The trace file contains no tracing information."); System.exit(-1); } // threadID is used to mark the interesting thread ThreadId tracing = null; for (ThreadId t : threads) { if (threadId == null) { if ("main".equals(t.getThreadName()) && (tracing == null || t.getJavaThreadId() < tracing.getJavaThreadId())) tracing = t; } else if (t.getJavaThreadId() == threadId.longValue()) { tracing = t; } } if (tracing == null) { System.err.println(threadId == null ? "Couldn't find the main thread." : "The thread you specified was not found."); System.exit(-1); return; } long startTime = System.nanoTime(); Slicer slicer = new Slicer(trace); if (cmdLine.hasOption("progress")) // the parameter process indicates that we need to monitor the process of slicing slicer.addProgressMonitor(new ConsoleProgressMonitor()); boolean multithreaded; if (cmdLine.hasOption("multithreaded")) { String multithreadedStr = cmdLine.getOptionValue("multithreaded"); multithreaded = ("1".equals(multithreadedStr) || "true".equals(multithreadedStr)); } else { multithreaded = Runtime.getRuntime().availableProcessors() > 1; } boolean warnUntracedMethods = cmdLine.hasOption("warn-untraced"); // give some warns when encounters untraced functions //sliceInstructionCollector implements the interface slice visitor, which travel the dependence graph SliceInstructionsCollector collector = new SliceInstructionsCollector(); // the collector is used to collect the instructions in the dependence graph according to the slice criterion. slicer.addSliceVisitor(collector); // zhushi by yhb if (warnUntracedMethods) slicer.addUntracedCallVisitor(new PrintUniqueUntracedMethods()); // the user need the untraced function info, so add untraced call visitor slicer.process(tracing, sc, multithreaded); //----------------------the key process of slicing!!! Set<InstructionInstance> slice = collector.getDynamicSlice(); // return the slice result from the collector long endTime = System.nanoTime(); Instruction[] sliceArray = slice.toArray(new Instruction[slice.size()]); // convert the set to array Arrays.sort(sliceArray); // in order to ensure the sequence of dynamic execution // show the slicing result System.out.println("The dynamic slice for criterion " + sc + ":"); for (Instruction insn : sliceArray) { System.out.format((Locale) null, "%s.%s:%d %s%n", insn.getMethod().getReadClass().getName(), insn.getMethod().getName(), insn.getLineNumber(), insn.toString()); } System.out.format((Locale) null, "%nSlice consists of %d bytecode instructions.%n", sliceArray.length); System.out.format((Locale) null, "Computation took %.2f seconds.%n", 1e-9 * (endTime - startTime)); }
From source file:Main.java
public static long[] toLongArray(final List<Long> list) { long[] ret = new long[list.size()]; int i = -1;//from ww w. jav a 2 s . c o m for (Long e : list) { ret[++i] = e.longValue(); } return ret; }
From source file:Main.java
public static long[] collectionToLongArray(Collection<Long> allKeys) { if (allKeys == null) return null; long[] values = new long[allKeys.size()]; int count = 0; for (Long allKey : allKeys) { values[count++] = allKey.longValue(); }/*from w w w .ja v a 2 s .co m*/ return values; }
From source file:Main.java
public static long nullAs(Long long1, long l) { if (long1 != null) l = long1.longValue(); return l;/*from w w w. j a va2 s . co m*/ }
From source file:Main.java
/** * Convert seconds to date time string.//w ww . j av a2s . c o m * * @param sec The seconds count from 1970-1-1 00:00:00 * @return String Date time string */ private static String toDateTimeString(Long sec) { Date date = new Date(sec.longValue() * 1000L); SimpleDateFormat dateFormat = new SimpleDateFormat(); String str = dateFormat.format(date); return str; }
From source file:Main.java
public static long getLongValue(Long value) { if (value == null) { return 0; }//w ww. j a va 2 s . co m return value.longValue(); }
From source file:Main.java
/** * unbox Long//from w w w .j a v a 2 s .c o m */ public static long unboxed(Long v) { return v == null ? 0 : v.longValue(); }
From source file:Main.java
public static final boolean sleep(final Long millis) { if (millis != null) { return sleep(millis.longValue()); }//from w w w .j av a2 s . c o m return true; }
From source file:Main.java
public static long nullAsNil(Long long1) { long l;/* w w w . ja v a 2 s. c o m*/ if (long1 == null) l = 0L; else l = long1.longValue(); return l; }
From source file:com.vmware.identity.openidconnect.protocol.JSONUtils.java
public static long getLong(JSONObject json, String key) throws ParseException { Validate.notNull(json, "json"); Validate.notEmpty(key, "key"); Object objectValue = json.get(key); if (objectValue == null) { throw new ParseException(String.format("json is missing %s member", key)); }/*from w ww . j a va 2 s. c o m*/ if (!(objectValue instanceof Long)) { throw new ParseException(String.format("json has non-long %s member", key)); } Long longValue = (Long) objectValue; return longValue.longValue(); }