Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
4,500
void (String[] args) { //myGlobalStart = System.nanoTime(); UUID uuid = null; String host = null; int port = -1; boolean keepRunning = false; // keep running after compilation ends until explicit shutdown if (args.length >= 3) { try { uuid = UUID.fromString(args[0]); } catch (Exception e) { System.err.println("Error parsing session id: " + e.getMessage()); System.exit(-1); } host = args[1]; try { port = Integer.parseInt(args[2]); } catch (NumberFormatException e) { System.err.println("Error parsing port: " + e.getMessage()); System.exit(-1); } if (args.length > 3) { keepRunning = Boolean.parseBoolean(args[3]); } } else { System.err.println("Insufficient number of parameters"); System.exit(-1); } try { final ExternalJavacProcess process = new ExternalJavacProcess(keepRunning); //final long connectStart = System.nanoTime(); if (process.connect(host, port)) { //final long connectEnd = System.nanoTime(); //System.err.println("Connected in " + TimeUnit.NANOSECONDS.toMillis(connectEnd - connectStart) + " ms; since start: " + TimeUnit.NANOSECONDS.toMillis(connectEnd - myGlobalStart)); process.myConnectFuture.channel().writeAndFlush( JavacProtoUtil.toMessage(uuid, JavacProtoUtil.createRequestAckResponse()) ); } else { System.err.println("Failed to connect to parent process"); System.exit(-1); } } catch (Throwable throwable) { throwable.printStackTrace(System.err); System.exit(-1); } }
main
4,501
void (Channel channel) { channel.pipeline().addLast(new ProtobufVarint32FrameDecoder(), new ProtobufDecoder(JavacRemoteProto.Message.getDefaultInstance()), new ProtobufVarint32LengthFieldPrepender(), new ProtobufEncoder(), new CompilationRequestsHandler() ); }
initChannel
4,502
void (File file) { context.channel().writeAndFlush(JavacProtoUtil.toMessage(sessionId, JavacProtoUtil.createSourceFileLoadedResponse(file))); }
javaFileLoaded
4,503
void (String line) { context.channel().writeAndFlush(JavacProtoUtil.toMessage(sessionId, JavacProtoUtil.createStdOutputResponse(line))); }
outputLineAvailable
4,504
void (Diagnostic<? extends JavaFileObject> diagnostic) { final JavacRemoteProto.Message.Response response = JavacProtoUtil.createBuildMessageResponse(diagnostic); context.channel().writeAndFlush(JavacProtoUtil.toMessage(sessionId, response)); }
report
4,505
void (JavacFileData data) { customOutputData(JavacFileData.CUSTOM_DATA_PLUGIN_ID, JavacFileData.CUSTOM_DATA_KIND, data.asBytes()); }
registerJavacFileData
4,506
void (String pluginId, String dataName, byte[] data) { final JavacRemoteProto.Message.Response response = JavacProtoUtil.createCustomDataResponse(pluginId, dataName, data); context.channel().writeAndFlush(JavacProtoUtil.toMessage(sessionId, response)); }
customOutputData
4,507
void (@NotNull OutputFileObject fileObject) { context.channel().writeAndFlush(JavacProtoUtil.toMessage(sessionId, JavacProtoUtil.createOutputObjectResponse(fileObject))); }
save
4,508
JavaCompilingTool () { String property = System.getProperty(JPS_JAVA_COMPILING_TOOL_PROPERTY); if (property != null) { final ServiceLoader<JavaCompilingTool> loader = ServiceLoader.load(JavaCompilingTool.class, JavaCompilingTool.class.getClassLoader()); for (JavaCompilingTool tool : loader) { if (property.equals(tool.getId()) || property.equals(tool.getAlternativeId())) { return tool; } } } return new JavacCompilerTool(); }
getCompilingTool
4,509
void () { boolean keepRunning = myKeepRunning; try { final JavacRemoteProto.Message result = compile(context, sessionId, options, files, cp, platformCp, modulePath, upgradeModulePath, srcPath, outs, new CanceledStatus() { @Override public boolean isCanceled() { return Boolean.TRUE.equals(myCanceled.get(sessionId)); } }); context.channel().writeAndFlush(result).awaitUninterruptibly(); } catch (Throwable throwable) { // in case of unexpected exception exit, to ensure the process is not stuck in a problematic state keepRunning = false; throwable.printStackTrace(System.err); try { // attempt to report via proto context.channel().writeAndFlush(JavacProtoUtil.toMessage(sessionId, JavacProtoUtil.createFailure(throwable.getMessage(), throwable))); } catch (Throwable ignored) { } } finally { myCanceled.remove(sessionId); // state cleanup if (keepRunning) { JavacMain.clearCompilerZipFileCache(); //noinspection CallToSystemGC System.gc(); } else { // in this mode this is only one-time compilation process that should stop after build is complete ExternalJavacProcess.this.stop(); } Thread.interrupted(); // reset interrupted status } }
run
4,510
boolean () { return Boolean.TRUE.equals(myCanceled.get(sessionId)); }
isCanceled
4,511
void () { ExternalJavacProcess.this.stop(); }
run
4,512
void () { try { //final long stopStart = System.nanoTime(); //System.err.println("Exiting. Since global start " + TimeUnit.NANOSECONDS.toMillis(stopStart - myGlobalStart)); final ChannelFuture future = myConnectFuture; if (future != null) { future.channel().close().await(); } myEventLoopGroup.shutdownGracefully(0, 15, TimeUnit.SECONDS).await(); //final long stopEnd = System.nanoTime(); //System.err.println("Stop completed in " + TimeUnit.NANOSECONDS.toMillis(stopEnd - stopStart) + "ms; since global start: " + TimeUnit.NANOSECONDS.toMillis(stopEnd - myGlobalStart)); System.exit(0); } catch (Throwable e) { e.printStackTrace(System.err); System.exit(-1); } }
stop
4,513
List<File> (List<String> paths) { final List<File> files = new ArrayList<>(paths.size()); for (String path : paths) { files.add(new File(path)); } return files; }
toFiles
4,514
void (UUID sessionId) { myCanceled.replace(sessionId, Boolean.FALSE, Boolean.TRUE); }
cancelBuild
4,515
boolean () { return "true".equals(System.getProperty(ENABLED_PARAM)); }
isEnabled
4,516
void (@NotNull JavaCompilingTool compilingTool, @NotNull JavaCompiler.CompilationTask task, @NotNull Iterable<String> options, @NotNull final DiagnosticOutputConsumer diagnosticConsumer) { if (compilingTool.isCompilerTreeAPISupported() && isEnabled()) { JavacReferenceCollector.installOn(task, new JavacReferenceCollector.Consumer<JavacFileData>() { @Override public void consume(JavacFileData data) { diagnosticConsumer.registerJavacFileData(data); } }); } }
beforeCompileTaskExecution
4,517
void (JavacFileData data) { diagnosticConsumer.registerJavacFileData(data); }
consume
4,518
Kind () { return Kind.SOURCE; }
getKind
4,519
boolean (String simpleName, Kind kind) { throw new UnsupportedOperationException(); }
isNameCompatible
4,520
NestingKind () { throw new UnsupportedOperationException(); }
getNestingKind
4,521
Modifier () { throw new UnsupportedOperationException(); }
getAccessLevel
4,522
URI () { return myUri; }
toUri
4,523
String () { throw new UnsupportedOperationException(); }
getName
4,524
long () { throw new UnsupportedOperationException(); }
getLastModified
4,525
boolean () { throw new UnsupportedOperationException(); }
delete
4,526
UUID (JavacRemoteProto.Message.UUID requestId) { return new UUID(requestId.getMostSigBits(), requestId.getLeastSigBits()); }
fromProtoUUID
4,527
LazyClassLoader (@Nullable Iterable<? extends File> files, ClassLoader parent) { return Iterators.isEmptyCollection(files)? null : new LazyClassLoader(Iterators.map(files, new Function<File, URL>() { @Override public URL fun(File f) { try { return f.toURI().toURL(); } catch (MalformedURLException e) { throw new AssertionError(e); } } }), parent); }
createFrom
4,528
URL (File f) { try { return f.toURI().toURL(); } catch (MalformedURLException e) { throw new AssertionError(e); } }
fun
4,529
DelegateClassLoader () { DelegateClassLoader delegate = myDelegate; if (delegate == null) { synchronized (myUrls) { delegate = myDelegate; if (delegate == null) { myDelegate = delegate = new DelegateClassLoader(Iterators.collect(myUrls, new ArrayList<URL>()).toArray(EMPTY_URL_ARRAY), myParent); } } } return delegate; }
getDelegate
4,530
URL (String name) { return getDelegate().findResource(name); }
findResource
4,531
URL (String name) { return super.findResource(name); }
findResource
4,532
void (@NotNull JavaCompilingTool compilingTool, @NotNull JavaCompiler.CompilationTask task, @NotNull Iterable<String> options, @NotNull DiagnosticOutputConsumer diagnosticConsumer) { }
beforeCompileTaskExecution
4,533
Collection<JavaCompilerToolExtension> () { return ourExtSupport.getExtensions(); }
getExtensions
4,534
JavaFileObject () { return myOriginal; }
getOriginal
4,535
Kind () { return myOriginal.getKind(); }
getKind
4,536
boolean (String simpleName, Kind kind) { return myOriginal.isNameCompatible(simpleName, kind); }
isNameCompatible
4,537
NestingKind () { return myOriginal.getNestingKind(); }
getNestingKind
4,538
Modifier () { return myOriginal.getAccessLevel(); }
getAccessLevel
4,539
URI () { return myOriginal.toUri(); }
toUri
4,540
String () { return myOriginal.getName(); }
getName
4,541
long () { return myOriginal.getLastModified(); }
getLastModified
4,542
boolean () { return myOriginal.delete(); }
delete
4,543
String () { // must implement like this because toString() is called inside com.sun.tools.javac.jvm.ClassWriter instead of getName() return getName(); }
toString
4,544
String (File file) { return file.getName(); }
fun
4,545
JavaFileObject (File file) { return new InputFileObject(file, myEncodingName, false); }
fun
4,546
JavaFileObject (File file) { return new InputFileObject(file, myEncodingName, true); }
fun
4,547
File (String s) { return new File(s); }
fun
4,548
String (File pathElement) { return context.getExplodedAutomaticModuleName(pathElement); }
getExplodedAutomaticModuleName
4,549
boolean () { return context.isCanceled(); }
isCanceled
4,550
StandardJavaFileManager () { return context.getStandardFileManager(); }
getStandardFileManager
4,551
void (@NotNull OutputFileObject obj) { try { context.consumeOutputFile(obj); } finally { onOutputFileGenerated(obj.getFile()); } }
consumeOutputFile
4,552
void (Diagnostic.Kind kind, @Nls String message) { context.reportMessage(kind, message); }
reportMessage
4,553
JavaFileObject (JavaFileObject fo) { return JavaFileObject.Kind.SOURCE.equals(fo.getKind())? new TransformableJavaFileObject(fo, mySourceTransformers) : fo; }
fun
4,554
Collection<String> (@Nullable String className, String fileName) { if (className != null) { Collection<String> dotsResult = myGeneratedToOriginatingMap.get(className.replace('/', '.')); // normalize classname: eclipse compiler sometimes outputs internal class names return dotsResult != null? dotsResult : myGeneratedToOriginatingMap.get(className.replace('.', '/')); } return myGeneratedToOriginatingMap.get(fileName); }
lookupOriginatingNames
4,555
boolean (@Nullable String className, String fileName) { if (className != null) { // normalize classname: eclipse compiler sometimes outputs internal class names return myGeneratedToOriginatingMap.containsKey(className.replace('/', '.')) || myGeneratedToOriginatingMap.containsKey(className.replace('.', '/')); } return myGeneratedToOriginatingMap.containsKey(fileName); }
hasOriginatingNames
4,556
File (Location location, @Nullable Iterable<URI> sources) { File dir = null; if (sources != null && location == StandardLocation.CLASS_OUTPUT) { for (URI uri : sources) { dir = getSingleOutputDirectory(location, uri); if (dir != null) { break; } } } if (dir == null) { dir = getSingleOutputDirectory(location, null); } return dir; }
findOutputDir
4,557
JavaFileObject (String qName) { final JavaFileObject result = myInputSourcesIndex.get(qName); if (result != null) { return result; } if (!Iterators.isEmpty(myInputSources)) { // the logic assumes the source is located in the directory structure reflecting the package name. // todo: repeatedly cut prefixes and try shorter suffixes final String uriSuffix = "/" + qName.replace('.', '/') + JavaFileObject.Kind.SOURCE.extension; for (JavaFileObject source : myInputSources) { final URI uri = source.toUri(); if (uri != null) { final String path = uri.getPath(); if (path != null && path.endsWith(uriSuffix)) { myInputSourcesIndex.put(qName, source); return source; } } } } return null; }
lookupInputSource
4,558
ClassLoader (Location location) { // ensure processor's loader will not resolve against JPS classes and libraries used in JPS final ClassLoader loader = LazyClassLoader.createFrom(getLocation(location), myContext.getStandardFileManager().getClass().getClassLoader()); if (loader instanceof Closeable) { myCloseables.add((Closeable)loader); } return loader; }
getClassLoader
4,559
File (final Location loc, final URI sourceUri) { if (loc == StandardLocation.CLASS_OUTPUT) { if (myOutputsMap.size() > 1 && sourceUri != null) { // multiple outputs case final File outputDir = findOutputDir(new File(sourceUri)); if (outputDir != null) { return outputDir; } } } final Iterable<? extends File> location = getStdManager().getLocation(loc); if (location != null) { final Iterator<? extends File> it = location.iterator(); if (it.hasNext()) { return it.next(); } } return null; }
getSingleOutputDirectory
4,560
File (File src) { File file = FileUtilRt.getParentFile(src); while (file != null) { for (Map.Entry<File, Set<File>> entry : myOutputsMap.entrySet()) { if (entry.getValue().contains(file)) { return entry.getKey(); } } file = FileUtilRt.getParentFile(file); } return null; }
findOutputDir
4,561
void () { final int counter = (myChecksCounter + 1) % 10; myChecksCounter = counter; if (counter == 0 && myContext.isCanceled()) { throw new CompilationCanceledException(); } }
checkCanceled
4,562
String (CharSequence classOrPackageName, CharSequence... suffix) { StringBuilder buf = new StringBuilder(); for (int i = 0, len = classOrPackageName.length(); i < len; i++) { char ch = classOrPackageName.charAt(i); buf.append(ch == '.'? '/' : ch); } for (CharSequence s : suffix) { buf.append(s); } return buf.toString(); }
externalizeFileName
4,563
Context () { return myContext; }
getContext
4,564
boolean (String current, final Iterator<String> remaining) { if ("-encoding".equalsIgnoreCase(current) && remaining.hasNext()) { final String encoding = remaining.next(); myEncodingName = encoding; return super.handleOption(current, new Iterator<String>() { private boolean encodingConsumed = false; @Override public boolean hasNext() { return !encodingConsumed || remaining.hasNext(); } @Override public String next() { if (!encodingConsumed) { encodingConsumed = true; return encoding; } return remaining.next(); } @Override public void remove() { if (encodingConsumed) { remaining.remove(); } } }); } return super.handleOption(current, remaining); }
handleOption
4,565
boolean () { return !encodingConsumed || remaining.hasNext(); }
hasNext
4,566
String () { if (!encodingConsumed) { encodingConsumed = true; return encoding; } return remaining.next(); }
next
4,567
void () { if (encodingConsumed) { remaining.remove(); } }
remove
4,568
String (Location location, JavaFileObject file) { final JavaFileObject _fo = unwrapFileObject(file); if (_fo instanceof JpsFileObject) { final String inferred = ((JpsFileObject)_fo).inferBinaryName(getLocation(location), isFileSystemCaseSensitive); if (inferred != null) { return inferred; } } return super.inferBinaryName(location, _fo); }
inferBinaryName
4,569
boolean (FileObject a, FileObject b) { final FileObject _a = unwrapFileObject(a); final FileObject _b = unwrapFileObject(b); if (_a instanceof JpsFileObject || _b instanceof JpsFileObject) { return _a.equals(_b); } return super.isSameFile(_a, _b); }
isSameFile
4,570
FileObject (FileObject a) { return a instanceof TransformableJavaFileObject ? ((TransformableJavaFileObject)a).getOriginal() : a; }
unwrapFileObject
4,571
JavaFileObject (JavaFileObject a) { return a instanceof TransformableJavaFileObject ? ((TransformableJavaFileObject)a).getOriginal() : a; }
unwrapFileObject
4,572
boolean (Location location) { try { if (!(location instanceof StandardLocation)) { return false; } final StandardLocation loc = StandardLocation.valueOf(location.getName()); if (loc == StandardLocation.PLATFORM_CLASS_PATH) { return myJavacBefore9; } return ourFSLocations.contains(loc); } catch (IllegalArgumentException ignored) { return false; // assume 'unknown' location is a non-FS location } }
isFileSystemLocation
4,573
Iterable<JavaFileObject> (File root) { try { final boolean isFile; FileOperations.Archive archive = myFileOperations.lookupArchive(root); if (archive != null) { isFile = true; } else { isFile = myFileOperations.isFile(root); } if (isFile) { // Not a directory; either a file or non-existent, create the archive try { if (archive == null) { archive = myFileOperations.openArchive(root, myEncodingName, location); } if (archive != null) { return archive.list(packageName.replace('.', '/'), kinds, recurse); } // fallback to default implementation return JpsJavacFileManager.super.list(location, packageName, kinds, recurse); } catch (IOException ex) { throw new IOException("Error reading file " + root + ": " + ex.getMessage(), ex); } } // is a directory or does not exist final File dir = new File(root, packageName.replace('.', '/')); // Generally, no directories should be included in result. If recurse:= false, // the fileOperations.listFiles(dir, recurse) output may contain children directories, so the filter should skip them too final BooleanFunction<File> kindsMatcher = ourKindFilter.getFor(kinds); final BooleanFunction<File> filter = recurse || !kinds.contains(JavaFileObject.Kind.OTHER) ? kindsMatcher : new BooleanFunction<File>() { @Override public boolean fun(File file) { return kindsMatcher.fun(file) && ( !(kinds.size() == 1 || JpsFileObject.findKind(file.getName()) == JavaFileObject.Kind.OTHER) /* the kind != OTHER */ || myFileOperations.isFile(file) ); } }; return Iterators.map(Iterators.filter(myFileOperations.listFiles(dir, recurse), filter), location.isOutputLocation()? myFileToInputFileObjectConverter : myFileToCachingInputFileObjectConverter); } catch (IOException e) { throw new RuntimeException(e); } }
fun
4,574
boolean (File file) { return kindsMatcher.fun(file) && ( !(kinds.size() == 1 || JpsFileObject.findKind(file.getName()) == JavaFileObject.Kind.OTHER) /* the kind != OTHER */ || myFileOperations.isFile(file) ); }
fun
4,575
boolean (File dir, File file) { final String dirPath = FileUtilRt.toCanonicalPath(dir.getAbsolutePath(), File.separatorChar, false); final String filePath = FileUtilRt.toCanonicalPath(file.getAbsolutePath(), File.separatorChar, false); final boolean trailingSlash = dirPath.endsWith("/"); if (filePath.length() < (trailingSlash? dirPath.length() : dirPath.length() + 1)) { return false; } if (!filePath.regionMatches(!isFileSystemCaseSensitive, 0, dirPath, 0, dirPath.length())) { return false; } if (!trailingSlash && filePath.charAt(dirPath.length()) != '/') { return false; } return true; }
isAncestor
4,576
void (File file) { final File parent = file.getParentFile(); if (parent != null) { myFileOperations.clearCaches(parent); } }
onOutputFileGenerated
4,577
void () { try { super.close(); } catch (IOException e) { throw new RuntimeException(e); } finally { myOutputsMap = Collections.emptyMap(); myInputSources = Collections.emptyList(); myInputSourcesIndex.clear(); myFileOperations.clearCaches(null); for (Closeable closeable : myCloseables) { try { closeable.close(); } catch (IOException ignored) { } } myCloseables.clear(); } }
close
4,578
void (String classOrResourceName, Iterable<String> originatingClassnames) { if (classOrResourceName != null) { Collection<String> names = null; for (String cn : originatingClassnames) { if (names == null) { names = myGeneratedToOriginatingMap.get(classOrResourceName); if (names == null) { myGeneratedToOriginatingMap.put(classOrResourceName, names = new HashSet<>()); } } names.add(cn); } } }
addAnnotationProcessingClassMapping
4,579
String (String errorDetails) { return errorDetails.isEmpty() ? myUnsupportedMessage : myUnsupportedMessage + ": " + errorDetails; }
getErrorMessage
4,580
Kind () { return myKind; }
getKind
4,581
JavaFileObject () { return null; }
getSource
4,582
long () { return 0; }
getPosition
4,583
long () { return 0; }
getStartPosition
4,584
long () { return 0; }
getEndPosition
4,585
long () { return 0; }
getLineNumber
4,586
long () { return 0; }
getColumnNumber
4,587
String () { return null; }
getCode
4,588
String (Locale locale) { return myMessage; }
getMessage
4,589
Kind (String name) { for (Kind kind : ourAvailableKinds) { if (kind != Kind.OTHER && name.regionMatches(true, name.length() - kind.extension.length(), kind.extension, 0, kind.extension.length())) { return kind; } } return Kind.OTHER; }
findKind
4,590
int () { return toUri().hashCode(); }
hashCode
4,591
boolean (Object obj) { // todo: check if this is fast enough to rely on URI.equals() here return this == obj || (obj instanceof JpsFileObject && toUri().equals(((JpsFileObject)obj).toUri())); }
equals
4,592
File () { return myOutputRoot; }
getOutputRoot
4,593
String () { return myRelativePath; }
getRelativePath
4,594
File () { return myFile; }
getFile
4,595
String () { return myClassName; }
getClassName
4,596
boolean () { return myIsGenerated; }
isGenerated
4,597
Iterable<File> () { return Iterators.filter(Iterators.map(getSourceUris(), new Function<URI, File>() { @Override public File fun(URI uri) { return "file".equalsIgnoreCase(uri.getScheme())? new File(uri) : null; } }), Iterators.<File>notNullFilter()); }
getSourceFiles
4,598
File (URI uri) { return "file".equalsIgnoreCase(uri.getScheme())? new File(uri) : null; }
fun
4,599
Iterable<URI> () { return mySources; }
getSourceUris