How to show full compile error messages info in Checker FrameWork with line numbers etc - checker-framework

I just started using Checker Framework and have a problem that is exactly reproducible on one of the example projects from authors of this framework. This project is available here:
https://github.com/typetools/checker-framework/tree/master/docs/examples/GradleExamples
When i run this command from root:
>gradle compileJava
i receive this compilation output:
public static /*#Nullable*/ Object nullable = null;
^
required: #Initialized #NonNull Object
list.add(null); // error on this line
^
required: #Initialized #NonNull String
2 errors
:compileJava FAILED
As you can see there is no any information about where errors occur like class name, line number in code etc.
I did not find any information in their official manual about any compiler parameters that can change output format appropriately. I want error messages look like this:
~\GradleExample.java:33 error: ';' expected
UPDATE:
I achieve this behaviour on 3 machines:
OS: Microsoft Windows 7 x64 Ultimate SP1 [version 6.1.7601];
Java: 1.8.0_73;
Gradle: 2.14.
OS: Microsoft Windows 10 x64 Pro [version 10.0.14393];
Java: 1.8.0_121;
Gradle: 3.4.1.
OS: Microsoft Windows 7 x64 Ultimate SP1 [version 6.1.7601];
Java: 1.8.0_121;
Gradle: 3.4.1.
The absence of line numbers and class names is experienced only when running with Gradle. I also tried to run checker with Maven and with Javac from command line and it worked perfectly.
To configure Checker Framework with Gradle i followed steps from manual. There are 3 steps:
Download framework;
Unzip it to create a checker-framework directory;
Configure Gradle to include Checker Framework on the classpath.
As i understand, Gradle will do steps 1 and 2 automatically when providing needed Checker Framework's jars through dependency management. Nevertheless i tried both options:
dependency management:
I simply downloaded example project and executed "gradle compileJava" from root
of the GradleJava7Example project.
manually writing paths in gradle build file:
allprojects {
tasks.withType(JavaCompile).all { JavaCompile compile ->
compile.options.compilerArgs = [
'-processor', 'org.checkerframework.checker.nullness.NullnessChecker',
'-processorpath', "C:\\checker-framework-2.1.10\\checker\\dist\\checker.jar",
"-Xbootclasspath/p:C:\\checker-framework-2.1.10\\checker\\dist\\jdk8.jar",
'-classpath', 'C:\\checker-framework-2.1.10\\checker\\dist\\checker.jar;C:\\checker-framework-2.1.10\\checker\\dist\\javac.jar'
]
}
}

I've found a workaround. I'll explain it later, but now if somebody has the same problem, add this line to you JavaCompile tasks configuration:
allprojects {
tasks.withType(JavaCompile).all { JavaCompile compile ->
System.setProperty("line.separator", "\n") // <<<<<< add this line
compile.options.compilerArgs = [
'-processor', 'org.checkerframework.checker.nullness.NullnessChecker',
'-processorpath', "${configurations.checkerFramework.asPath}",
"-Xbootclasspath/p:${configurations.checkerFrameworkAnnotatedJDK.asPath}"
]
}
}
First of all i must say that problem was not in Checker Framework at all. I managed to reproduce the same behavior as mentioned in question without Checker Framework. I have created a little custom Annotation Processor. Here is the code:
#SupportedSourceVersion(value = SourceVersion.RELEASE_8)
#SupportedAnnotationTypes(value = {"*"})
public class MyProcessor extends AbstractProcessor{
#Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
String sepr = System.getProperty("line.separator");
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "[error code] " + sepr + " catched!!!");
return true;
}
}
As you can see, all it does is printing a message right away from start. Note that i used a line separator provided by java.lang.System class to split message. When i registered this processor and tried to run "gradle compileJava" from gradle project it produced the following output:
:compileJava
catched!!!
1 error
:compileJava FAILED
The property "line.separator" for Windows OS returns CR+LF: "\r\n". I don't know why Messager.printMessage(Diagnostic.Kind kind, CharSequence msg) has this behaviour, because when i type System.err.print("[error code] " + sepr + " catched!!!") instead, everything works fine (note also that this problem occur only when i use Gradle, if i run manually javac with all arguments or use Maven everyting is fine).
I found that if i substitude the provided by system separator with simple "\n" symbol compiler error messages are displayed correctly.
For now i choose this solution as a workaround.

Related

Pitest is failing showing: No mutations found due to the supplied classpath or filters + Gradle

I'm trying to run a pitest report on a gradle + kotlin project, but I get the following error:
Exception in thread "main" org.pitest.help.PitHelpError: No mutations found. This probably means there is an issue with either the supplied classpath or filters.
See http://pitest.org for more details.
at org.pitest.mutationtest.tooling.MutationCoverage.checkMutationsFound(MutationCoverage.java:352)
at org.pitest.mutationtest.tooling.MutationCoverage.runReport(MutationCoverage.java:132)
at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:123)
at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:54)
at org.pitest.mutationtest.commandline.MutationCoverageReport.runReport(MutationCoverageReport.java:98)
at org.pitest.mutationtest.commandline.MutationCoverageReport.main(MutationCoverageReport.java:45)
I tried everything that I found on google but still not working for me:
This is my build.gradle config
plugins {
id 'groovy-gradle-plugin'
id 'info.solidsoft.pitest' version '1.7.4'
}
repositories {
maven { url "https://plugins.gradle.org/m2/" }
gradlePluginPortal()
}
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20'
implementation 'com.github.jengelman.gradle.plugins:shadow:6.1.0'
}
pitest {
targetClasses = ['com.project.root.to.test.with.pitest.src*'] //by default
"${project.group}.*"
pitestVersion = '1.7.4' //not needed when a default PIT version should be used
threads = 4
outputFormats = ['XML', 'HTML']
timestampedReports = false
}
I tried this targetClasses in a different ways:
targetClasses = ['com.project.root.to.test.with.pitest.src.*'] //by default
targetClasses = ['com/project/root/to/test/with/pitest/src*'] //by default
Can someone help me, please?
You look to be trying to supply pitest with a source folder
com.project.root.to.test.with.pitest.src.
Pitest works against the compiled bytecode, not the source files. It expects
a glob that matches against the package.
com.example.*
I've experienced this same issue today. You'll need to make sure all references to pitest use the same version 1.7.4. This includes
plugin: id 'info.solidsoft.pitest' version '1.7.4'
pitestVersion: pitestVersion.set('1.7.4')
dependency: testCompile
'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.7.4'
Which out changing all references, then it will break.

How to configure plugin verifier as it runs during JetBrains Marketplace admission?

Can you advise how to configure the plugin verifier so it would return errors as JetBrains marketplace does, please?
Error from the marketplace:
[plugin] depends on plugin com.jetbrains.php that couldn't be resolved with respect to IntelliJ IDEA Ultimate IU-202.8194.7 (2020.2.4)
Note that the [plugin] cannot be installed into IntelliJ IDEA Ultimate IU-202.8194.7 (2020.2.4) without mandatory com.jetbrains.php
Found 1 incompatibility with IntelliJ IDEA Ultimate IU-202.8194.7 (2020.2.4), some of which may be caused by the missing dependencies.
When running runPluginVerifier locally everything is fine:
2020-12-11T13:01:29 [main] INFO verification - Finished 1 of 2 verifications (in 3.1 s): IU-202.8194.7 against com.lokalise.jetbrainsideplugin:1.0.0-alpha: Compatible
2020-12-11T13:01:30 [main] INFO verification - Finished 2 of 2 verifications (in 3.6 s): PS-202.6948.87 against com.lokalise.jetbrainsideplugin:1.0.0-alpha: Compatible
I would like to catch such an error during CI at most instead of throwing the plugin at the marketplace team.
Here is the gradle task configuration (Kotlin):
import org.jetbrains.intellij.tasks.RunPluginVerifierTask
...
tasks.runPluginVerifier {
ideVersions("PS-202.6948.87,IU-202.8194.7")
setFailureLevel(RunPluginVerifierTask.FailureLevel.ALL)
}
I struggled with it quite a bit. Found it.
tasks {
runPluginVerifier {
ideVersions.set(listOf("PS-202.6948.87","IU-202.8194.7"))
}
...
}

Why is Gradle failing on :linkDebugTestLinux in my Kotlin multiplatform project?

I'm porting a C# library to Kotlin to take advantage of multiplatform. When running the build task, it fails in the subtask linkDebugTestLinux.
For context, I'm using IDEA Ultimate on Manjaro. I'm certain there's nothing wrong with my code as compileKotlinLinux finishes without error.
There are zero DDG results for "linkDebugTestLinux" and nothing helpful for "konan could not find home" or "kotlin native ...". After hours of stitching together incomplete and outdated examples from the official docs, I've given up.
My build.gradle.kts:
plugins {
kotlin("multiplatform") version "1.3.40"
}
repositories {
mavenCentral()
}
dependencies {
commonMainImplementation("org.jetbrains.kotlin:kotlin-stdlib")
commonTestImplementation("org.jetbrains.kotlin:kotlin-test-common")
commonTestImplementation("org.jetbrains.kotlin:kotlin-test-annotations-common")
}
kotlin {
// js() // wasn't the issue
linuxX64("linux")
}
Output of task build without args:
> Configure project :
Kotlin Multiplatform Projects are an experimental feature.
> Task :compileKotlinLinux
[...unused param warnings...]
> Task :compileKotlinMetadata
[...unused param warnings...]
> Task :metadataMainClasses
> Task :metadataJar
> Task :assemble
> Task :linuxProcessResources NO-SOURCE
> Task :linuxMainKlibrary
> Task :linkDebugTestLinux FAILED
e: Could not find "/home/username/" in [/home/username/path/to/the/repo, /home/username/.konan/klib, /home/username/.konan/kotlin-native-linux-1.3/klib/common, /home/username/.konan/kotlin-native-linux-1.3/klib/platform/linux_x64].
[...snip...]
BUILD FAILED in 16s
4 actionable tasks: 4 executed
Process 'command '/usr/lib/jvm/java-8-openjdk/bin/java'' finished with non-zero exit value 1
In the boilerplate I omitted it suggests to use --debug, so I've uploaded that here.
After some investigation, it was assumed that the problem is in the path. In the debug log, you got the /home/yoshi/,/ fragment. As far as this directory name was unexpected, the compiler interpreted this , as a delimiter between lib names. So, it tried to find library /home/yoshi/, that was obviously unavailable.
For now, I would recommend you to change the directory name to be something trivial.

ClickOnce fails on download

OK, I have a similar problem as Download ClickOnce fails from setup.exe and Download ClickOnce fails from setup.exe , where I have deployed a ClickOnce installer for a desktop app I am selling.
Different than those examples, I am using Visual Studio 2012 (Pro Version). Using .Net 3.5. I am deploying on a hosted LINUX machine. It worked for me and other people running Windows 7 & 8, possibly earlier versions of Widnows. Then after running a few tests in Debug mode, I built and deployed in Release mode. Now, the auto-installer breaks when it gets to the spot where it wants to download the .application file. Here's the log file.
The following properties have been set:
Property: [AdminUser] = true {boolean}
Property: [InstallMode] = HomeSite {string}
Property: [NTProductType] = 1 {int}
Property: [ProcessorArchitecture] = AMD64 {string}
Property: [VersionNT] = 6.2.0 {version}
Running checks for package 'Microsoft Visual Basic PowerPacks 10.0', phase BuildList
Attempting to find 'Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=YADDAYADDA' in the Global Assembly Cache
AssemblyCheck: Error querying assembly info: -2147024894
Attempting to find 'Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=YADDAYADDA, processorArchitecture=msil' in the Global Assembly Cache
Assembly found at 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualBasic.PowerPacks.Vs\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualBasic.PowerPacks.Vs.dll'
Setting value '11.0.50727.1 {version}' for property 'VBPowerPacksInstalled'
The following properties have been set for package 'Microsoft Visual Basic PowerPacks 10.0':
Property: [VBPowerPacksInstalled] = 11.0.50727.1 {version}
Running checks for command 'VBPowerPacks\VisualBasicPowerPacksSetup.exe'
Result of running operator 'ValueExists' on property 'VBPowerPacksInstalled': true
Result of checks for command 'VBPowerPacks\VisualBasicPowerPacksSetup.exe' is 'Bypass'
'Microsoft Visual Basic PowerPacks 10.0' RunCheck result: No Install Needed
Running checks for package '.NET Framework 3.5 SP1', phase BuildList
Reading value 'SP' of registry key 'HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5'
Read integer value 1
Setting value '1 {int}' for property 'DotNet35SP'
The following properties have been set for package '.NET Framework 3.5 SP1': Property: [DotNet35SP] = 1 {int}
Running checks for command 'DotNetFX35SP1\dotNetFx35setup.exe'
Result of running operator 'ValueGreaterThanEqualTo' on property 'DotNet35SP' and value '1': true
Result of checks for command 'DotNetFX35SP1\dotNetFx35setup.exe' is 'Bypass'
'.NET Framework 3.5 SP1' RunCheck result: No Install Needed
Launching Application.
URLDownloadToCacheFile failed with HRESULT '-2146697205'
Error: An error occurred trying to download 'http://www.mywebsite.com/ProductName/Downloads/oneclick/ProductName.application'.
I've looked at https://msdn.microsoft.com/en-us/library/ms229001.aspx , after which I set the MIME type of .application to x-ms-application. No difference.
When I put the url http://www.mywebsite.com/ProductName/Downloads/oneclick/ProductName.application into my browser, I get the text of the file, rather than a download.
Any thoughts??? Thanks!
OK, the first thing that got me closer to the solution was simply to reboot the PC I was dwonloading onto. This got me further into the install, but I then ran into another problem, the solution to which I found at ClickOnce application replace current installed fliles . Clearing out the folder C:\Users\Charles\AppData\Local\Apps\2.0got me to where I could install and run the app fully.
Window application in C #. My solution, I hope it serves someone. The domain server was damaged, I just changed the IP of the new DNS server. It was not necessary to join that new domain server IP.
The "An error occurred trying to download.." error occurs with one of our click-once apps and the solution is to turn off IE Enhanced Security from Server Manager (Server 2012R2+) on the target machine.

Which is the environment variable for Mono/C# library DLLs?

I'm running the frozen Debian 7.0 Testing/Wheezy.
Here is my C# sample code:
using System.Windows.Forms;
using System.Drawing;
public class Simple : Form
{
public Simple()
{
Text = "Simple";
Size = new Size(250, 200);
CenterToScreen();
}
static public void Main()
{
Application.Run(new Simple());
}
}
I got the above C# WinForms code sample working in Monodevelop by using the System.Drawing and System.Windows.Forms references as well as in the command line when compiling with the following command:
mcs /tmp/Simple.cs -r:/usr/lib/mono/4.0/System.Windows.Forms.dll \
-r:/usr/lib/mono/4.0/System.Drawing.dll
I'm trying to make the mcs command work without needing to use the -r switch/parameter (which, by the way, I cannot find information on by looking through man mcs - I basically found this switch/parameter on some random website and it worked).
To check if it worked temporarily, I issued
export PATH=$PATH:/usr/lib/mono/4.0/System.Windows.Forms.dll:/usr/lib/mono/4.0/System.Drawing.dll
prior to issuing mcs /tmp/Simple.cs, which failed with the errors within the following output:
deniz#debian:~$ cd /tmp
deniz#debian:/tmp$ export PATH=$PATH:/usr/lib/mono/4.0/System.Windows.Forms.dll:/usr/lib/mono/4.0/System.Drawing.dll
deniz#debian:/tmp$ mcs Simple.cs
Simple.cs(1,14): error CS0234: The type or namespace name `Windows' does not exist in the namespace `System'. Are you missing an assembly reference?
Simple.cs(2,14): error CS0234: The type or namespace name `Drawing' does not exist in the namespace `System'. Are you missing an assembly reference?
Compilation failed: 2 error(s), 0 warnings
deniz#debian:/tmp$
The above output tells me that the mcs compiler/utility is not seeing the dll files but I don't know what else to try.
Any help in getting the WinForms and Drawing libraries to be automatically “looked at” would be greatly appreciated!
I'm trying to make the mcs command work without needing to use the -r switch/parameter
This is not possible, mcs will not look for libraries unless you tell it to look for them (which is done with -r:...).

Resources