Compilation failed 1 error s 0 warnings

Hi I follow the https://github.com/dotnet/coreclr/blob/master/Documentation/linux-instructions.md to build my first C# Helloworld application. I am able to run the application in my ubuntu box. The...

Thanks for the help.

I am trying to use the following as a TCP server listening to clients request.
IPAddress ipAd = IPAddress.Parse(«192.168.1.24»);
TcpListener myList = new TcpListener(ipAd, 8001);
TcpListener myList = new TcpListener(ipAd, 8001);

AND the other side the code also a HTTP client using the following:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urladdr);

This code was working in my VS2013 in my Window machine. I am trying to port to Linux to see if it works. So I delete all the C# code in the file and only have the import.

Anyway, I am now only have «using statement» to try if the namesapce are resolved under Linux.

This is my test code now.

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;

namespace ClientServer
{
public class ClientServer
{
public static void Main()
{
}
}

}

By the way,
I steal the mono’s System.Net.dll, it seems fix the following problems.
error CS0234: The type or namespace nameNet’ does not exist in the namespace System’. Are you missing an assembly reference? ClientServer.cs(7,14):

But I got another error:
error CS0234: The type or namespace name Sockets' does not exist in the namespaceSystem.Net’. Are you missing an assembly reference?

Here are commands I ran on Linux. i am not sure should I refer to mono’s dll file, please advise.

Ubuntu:/coreclr-demo/runtime$ mono —version
Mono JIT compiler version 4.0.1 (tarball Tue May 12 15:39:23 UTC 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
……
Ubuntu:/coreclr-demo/runtime$ ls /usr/lib/mono/4.0/System.Net.dll
/usr/lib/mono/4.0/System.Net.dll
Uuntu:~/coreclr-demo/runtime$ mcs -nostdlib -noconfig /r:../packages/System.Console.4.0.0-beta-22703/lib/contract/System.Console.dll /r:../packages/System.Runtime.4.0.20-beta-22703/lib/contract/System.Runtime.dll /r:../packages/System.Linq.4.0.0-beta-22703/lib/contract/System.Linq.dll /r:/usr/lib/mono/4.0/System.Net.dll test.cs
test.cs(7,18): error CS0234: The type or namespace name Sockets' does not exist in the namespaceSystem.Net’. Are you missing an assembly reference?
Compilation failed: 1 error(s), 0 warnings

Compilation crashes in Basic.Gen.exe in native code. I’m running CppSharp for 64 bits on osx 10.10 using a recommended llvm x64 version. Is this crash known? Stacktrace:

==== Building CppSharp.AST (release_x64) ====
make[1]: Nothing to be done for `all'.
==== Building CppSharp.Runtime (release_x64) ====
make[1]: Nothing to be done for `all'.
==== Building CppSharp.CppParser (release_x64) ====
==== Building CppSharp.Parser.CSharp (release_x64) ====
make[1]: Nothing to be done for `all'.
==== Building CppSharp (release_x64) ====
make[1]: Nothing to be done for `all'.
==== Building CppSharp.Generator (release_x64) ====
make[1]: Nothing to be done for `all'.
==== Building CppSharp.Generator.Tests (release_x64) ====
make[1]: Nothing to be done for `all'.
==== Building Basic.Native (release_x64) ====
==== Building Basic.Gen (release_x64) ====
==== Building Basic.CSharp (release_x64) ====
Running pre-build commands
mono --debug "../lib/Release_x64/Basic.Gen.exe"
Stacktrace:

  at <unknown> <0xffffffff>
  at CppSharp.ConsoleDriver.Run (CppSharp.ILibrary) [0x00007] in /Users/Stephan/Sourcecode/CppSharp/src/Generator/Driver.cs:406
  at CppSharp.Tests.Basic.Main (string[]) [0x00007] in /Users/Stephan/Sourcecode/CppSharp/tests/Basic/Basic.cs:38
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

Native stacktrace:


Debug info from gdb:

(lldb) command source -s 0 '/tmp/mono-gdb-commands.aXTkz6'
Executing commands in '/private/tmp/mono-gdb-commands.aXTkz6'.
(lldb) process attach --pid 91290
Process 91290 stopped
Executable module set to "/usr/local/bin/mono".
Architecture set to: x86_64h-apple-macosx.
(lldb) thread list
Process 91290 stopped
* thread #1: tid = 0x436227, 0x00007fff8a798902 libsystem_kernel.dylib`__wait4 + 10, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  thread #2: tid = 0x436228, 0x00007fff8a79351a libsystem_kernel.dylib`semaphore_wait_trap + 10
  thread #3: tid = 0x436229, 0x00007fff8a799232 libsystem_kernel.dylib`kevent64 + 10, queue = 'com.apple.libdispatch-manager'
(lldb) thread backtrace all
* thread #1: tid = 0x436227, 0x00007fff8a798902 libsystem_kernel.dylib`__wait4 + 10, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x00007fff8a798902 libsystem_kernel.dylib`__wait4 + 10
    frame #1: 0x000000010cb1d9d1 mono`mono_handle_native_sigsegv(signal=<unavailable>, ctx=<unavailable>) + 433 at mini-exceptions.c:2323
    frame #2: 0x000000010cb73e34 mono`mono_arch_handle_altstack_exception(sigctx=0x000000010cfecf48, fault_addr=<unavailable>, stack_ovf=0) + 84 at exceptions-amd64.c:861
    frame #3: 0x000000010ca83bab mono`mono_sigsegv_signal_handler(_dummy=<unavailable>, _info=<unavailable>, context=<unavailable>) + 379 at mini.c:6858
    frame #4: 0x00007fff8a25ef1a libsystem_platform.dylib`_sigtramp + 26
    frame #5: 0x000000010ccb0d51 mono`monoeg_g_hash_table_lookup [inlined] monoeg_g_hash_table_lookup_extended(hash=<unavailable>, value=<unavailable>) + 48 at ghashtable.c:331
    frame #6: 0x000000010ccb0d21 mono`monoeg_g_hash_table_lookup(hash=<unavailable>, key=0x0000000000002d6c) + 17 at ghashtable.c:311
    frame #7: 0x000000010cbba29e mono`mono_get_method_full(image=<unavailable>, token=<unavailable>, klass=<unavailable>, context=<unavailable>) + 158 at loader.c:1842
    frame #8: 0x000000010cbbc3be mono`find_method_in_class [inlined] mono_get_method(image=<unavailable>, token=<unavailable>, klass=0x00007fbeb38536e0) + 8 at loader.c:1821
    frame #9: 0x000000010cbbc3b6 mono`find_method_in_class(klass=0x00007fbeb38536e0, name=0x000000010f90aa5c, qname=0x0000000000000000, fqname=0x0000000000000000, sig=0x00007fbeb403ec70, from_class=0x00007fbeb38536e0) + 310 at loader.c:629
    frame #10: 0x000000010cbbc05f mono`find_method(in_class=<unavailable>, ic=<unavailable>, name=0x000000010f90aa5c, sig=0x00007fbeb403ec70, from_class=<unavailable>) + 271 at loader.c:699
    frame #11: 0x000000010cbbc859 mono`method_from_memberref(image=<unavailable>, idx=<unavailable>, typespec_context=<unavailable>, used_context=<unavailable>) + 697 at loader.c:1055
    frame #12: 0x000000010cbba42e mono`mono_get_method_from_token(image=0x00007fbeb4029200, token=<unavailable>, klass=<unavailable>, context=0x0000000000000000, used_context=<unavailable>) + 158 at loader.c:1726
    frame #13: 0x000000010cbba2c8 mono`mono_get_method_full(image=0x00007fbeb4029200, token=167772162, klass=0x0000000000000000, context=0x0000000000000000) + 200 at loader.c:1850
    frame #14: 0x000000010cc4898b mono`mono_custom_attrs_from_index(image=0x00007fbeb4029200, idx=46) + 331 at reflection.c:8748
    frame #15: 0x000000010ca8be0f mono`mono_method_to_ir [inlined] is_jit_optimizer_disabled(m=0x00007fbeb403d2b0) + 143 at method-to-ir.c:6762
    frame #16: 0x000000010ca8bd80 mono`mono_method_to_ir(cfg=0x00007fbeb400dc00, method=0x00007fbeb403d2b0, start_bblock=0x0000000000000000, end_bblock=0x0000000000000000, return_var=0x0000000000000000, inline_args=0x0000000000000000, inline_offset=<unavailable>, is_virtual_call=<unavailable>) + 64 at method-to-ir.c:7042
    frame #17: 0x000000010ca8060e mono`mini_method_compile(method=0x00007fbeb403d2b0, opts=370239999, domain=0x00007fbeb3414240, flags=<unavailable>, parts=0) + 2766 at mini.c:5281
    frame #18: 0x000000010ca82e3c mono`mono_jit_compile_method_with_opt [inlined] mono_jit_compile_method_inner(method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, method=0x00007fbeb403d2b0, opt=<unavailable>) + 194 at mini.c:6024
    frame #19: 0x000000010ca82d7a mono`mono_jit_compile_method_with_opt(method=<unavailable>, opt=<unavailable>, ex=0x00007fff53185fb0) + 1274 at mini.c:6296
    frame #20: 0x000000010ca8282a mono`mono_jit_compile_method(method=0x00007fbeb403d2b0) + 42 at mini.c:6333
    frame #21: 0x000000010cb1eeed mono`common_call_trampoline(m=<unavailable>, vtable_slot=<unavailable>, need_rgctx_tramp=0, regs=<unavailable>, code=<unavailable>, tramp=<unavailable>, vt=<unavailable>) + 1069 at mini-trampolines.c:584
    frame #22: 0x000000010cf91172
    frame #23: 0x000000010cfd314f
    frame #24: 0x000000010cfd2db4
    frame #25: 0x000000010ca86019 mono`mono_jit_runtime_invoke(method=<unavailable>, obj=0x0000000000000000, params=0x00007fff53186798, exc=0x000000010cfd2d70) + 1641 at mini.c:6735
    frame #26: 0x000000010cc2dd6e mono`mono_runtime_invoke(method=0x00007fbeb3415ba0, obj=0x0000000000000000, params=0x00007fff53186798, exc=0x0000000000000000) + 110 at object.c:2842
    frame #27: 0x000000010cc333a8 mono`mono_runtime_exec_main(method=0x00007fbeb3415ba0, args=<unavailable>, exc=0x0000000000000000) + 376 at object.c:4099
    frame #28: 0x000000010caef390 mono`mono_main [inlined] main_thread_handler + 7776 at driver.c:1064
    frame #29: 0x000000010caef354 mono`mono_main(argc=<unavailable>, argv=<unavailable>) + 7716 at driver.c:2022
    frame #30: 0x00007fff856e05c9 libdyld.dylib`start + 1
    frame #31: 0x00007fff856e05c9 libdyld.dylib`start + 1

  thread #2: tid = 0x436228, 0x00007fff8a79351a libsystem_kernel.dylib`semaphore_wait_trap + 10
    frame #0: 0x00007fff8a79351a libsystem_kernel.dylib`semaphore_wait_trap + 10
    frame #1: 0x000000010cca9187 mono`mono_sem_wait(sem=0x000000010cdcb908, alertable=1) + 23 at mono-semaphore.c:103
    frame #2: 0x000000010cc2b368 mono`finalizer_thread(unused=<unavailable>) + 120 at gc.c:1077
    frame #3: 0x000000010cc0b486 mono`start_wrapper [inlined] start_wrapper_internal + 426 at threads.c:663
    frame #4: 0x000000010cc0b2dc mono`start_wrapper(data=<unavailable>) + 44 at threads.c:710
    frame #5: 0x000000010ccae86e mono`inner_start_thread(arg=<unavailable>) + 222 at mono-threads-posix.c:88
    frame #6: 0x00007fff85893268 libsystem_pthread.dylib`_pthread_body + 131
    frame #7: 0x00007fff858931e5 libsystem_pthread.dylib`_pthread_start + 176
    frame #8: 0x00007fff8589141d libsystem_pthread.dylib`thread_start + 13

  thread #3: tid = 0x436229, 0x00007fff8a799232 libsystem_kernel.dylib`kevent64 + 10, queue = 'com.apple.libdispatch-manager'
    frame #0: 0x00007fff8a799232 libsystem_kernel.dylib`kevent64 + 10
    frame #1: 0x00007fff9241dd91 libdispatch.dylib`_dispatch_mgr_invoke + 247
    frame #2: 0x00007fff9241da6a libdispatch.dylib`_dispatch_mgr_thread + 52
(lldb) detach

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

(lldb) quit
Process 91290 detached
(lldb) make[1]: *** [prebuild] Abort trap: 6
make: *** [Basic.CSharp] Error 2



asked

May 28, 2021


by


(120 points)



I have been trying to use the Interactive Console to trouble shoot errors in my C# code.

However, most of the time (like 99/100 times), selecting the stderr tab above the console will give me an error line that is formatted like this:

«Compilation failed: 1 error(s), 0 warnings»

And it won’t include any actual details on the warnings or errors.

However, if I change the input method to «Text» instead of the Interactive Console then it properly gives explanations on any errors that are in the code.

I have a very annoying workaround to getting this working by going back and forth, but I’m not sure what is causing the lack of error information. This did not use to be the case, and sometimes I do get the correct error information.

By default I have been using Chrome.

Example error output formatting (note — there are really small errors in here just to proc an error).

Example 1a: Interactive Console: https://i.ibb.co/nPyLdy2/ICError1a.png

1 Answer



answered

Jan 2, 2022


by
xDELLx

(10,380 points)



I have some C# code using Tuples:

public class Test {
    static void Main() {
        Tuple<int, int> t = Tuple.Create(0, 1);
    }
}

I tried compiling using

mcs -debug+ -o Test.exe Test.cs

but it gives the error

Test.cs(3,9): error CS0246: The type or namespace name `Tuple' could not be found. Are you missing a using directive or an assembly reference?
Compilation failed: 1 error(s), 0 warnings

I thought it might be trying to compile against an old version of mscorlib which lacks tuples. Looking at the man page, it seems you specify the version using -sdk:4, but that doesn’t work either:

$ mcs -sdk:4 Test.cs

Unhandled Exception: System.TypeLoadException: Type 'System.Dynamic.BinaryOperationBinder' not found in assembly 'System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'                                                                                                                                                                         

(followed by a stack trace).

I am running:

$ mcs --version
Mono C# compiler version 2.10.8.1

on Ubuntu Precise. According to the documentation, Mono has supported .NET 4.0 since version 2.8, and in particular supports System.Tuple, so that shouldn’t be the issue.

How do you compile code that uses Tuples?

When I compile a Java project using IntelliJ IDEA, it gives me the following output (and error):

Information:Eclipse compiler 4.6.2 was used to compile java sources
Information:Module "sinoWeb" was fully rebuilt due to project configuration/dependencies changes
Information:2017/3/23 11:44 - Compilation completed with 1 error and 0 warnings in 5m 32s 949ms
Error:java: Compilation failed: internal java compiler error

I’m quite confused confused by this! Below are my settings:

enter image description

enter image description here

Toastrackenigma's user avatar

asked Mar 23, 2017 at 3:46

ieatczp's user avatar

5

  1. On Intellij IDEA Ctrl + Alt + S to open settings.
  2. Build, Execution, Deployment -> Compiler -> Java Compiler
  3. choose your java version from Project bytecode version
  4. Uncheck Use compiler from module target JDK when possible
  5. click apply and ok.

answered Oct 31, 2018 at 10:58

Musab Bozkurt's user avatar

Musab BozkurtMusab Bozkurt

1,5711 gold badge6 silver badges5 bronze badges

5

I solved this issue by increasing the default value(700) of Build process heap size on IntelliJ’s compiler settings.

enter image description here

answered Feb 2, 2018 at 15:17

sezerug's user avatar

sezerugsezerug

1,0969 silver badges10 bronze badges

1

I changed my compiler to Eclipse and run my project. Afterwards changed back to Javac and problem solved. I don’t know exact problem but it can help who is looking for solution.

intellij java compiler

answered Jul 24, 2017 at 7:41

omerhakanbilici's user avatar

omerhakanbiliciomerhakanbilici

8641 gold badge19 silver badges26 bronze badges

2

In my case, using Java 11, I had:

 public List<String> foo() {
   ...
   return response.readEntity(new GenericType<List<String>>() {});

and Intellij suggested I should use <> instead of GenericType<List<String>>, as such:

 public List<String> foo() {
   ...
   return response.readEntity(new GenericType<>() {});

I did that in four functions and the project stopped compiling with an internal compiler error, reverted and it compiled again. Looks like a bug with type inference.

answered Jul 26, 2019 at 7:16

Tony BenBrahim's user avatar

Tony BenBrahimTony BenBrahim

6,9522 gold badges38 silver badges48 bronze badges

3

For me the module’s target bytecode version was set to 5. I changed it to 8 and the error is gone:

module's bytecode version setting

answered Apr 17, 2020 at 10:40

velocity's user avatar

velocityvelocity

1,50019 silver badges23 bronze badges

In JIdea 2020.1.2 and above,

This is may be the language-level set in Project Structure is not compatible with the target byte-code version.

You have to change the target bytecode version .

  1. Go to Settings [ Ctrl+Alt+S ]
  2. Select Java Compiler
  3. Select module in the table
  4. Change the byte-code version to map what you selected in the previous step for language-level

enter image description here

NOTE :
How to check the language-level

  1. Go to Project Structure [ Ctrl+Alt+Shift+S
    ]
  2. Select Modules sub section
  3. Select each module
  4. Under sources-section, check Language Level

enter image description here

answered Aug 8, 2020 at 3:04

prime's user avatar

primeprime

13.9k13 gold badges92 silver badges127 bronze badges

1

In my case it was because of lombok library with intellij 2019.2 & java11.

According to this IDEA bug after workaround idea works again:

Disable all building from intelliJ and dedicate the build to Maven.

enter image description here

answered Sep 16, 2019 at 10:27

Filomat's user avatar

FilomatFilomat

6831 gold badge11 silver badges15 bronze badges

3

Per-module bytecode version settings

I met the same problem

I solved it by changing the Target bytecode error from 1.5 to 8

Brad Mace's user avatar

Brad Mace

27k17 gold badges99 silver badges146 bronze badges

answered Jan 9, 2021 at 9:49

kl w's user avatar

kl wkl w

811 silver badge2 bronze badges

You have to disabled the Javac Options: Use compiler from module target JDK when possible.
enter image description here

Maximilian Ast's user avatar

answered Apr 17, 2019 at 14:04

Duc Hiep Hoang's user avatar

0

In my case, it was response type in restTemplate:
enter image description here

ResponseEntity<Map<String, Integer>> response = restTemplate.exchange(
        eurl,
        HttpMethod.POST,
        requestEntity,
        new ParameterizedTypeReference<>() { <---- this causes error
        }
);

Should be like this:

ParameterizedTypeReference<Map<String, Integer>> responseType = new ParameterizedTypeReference<>() {};

ResponseEntity<Map<String, Integer>> response = restTemplate.exchange(
        url,
        HttpMethod.POST,
        requestEntity,
        responseType
);

answered May 19, 2020 at 9:38

dev_in_progress's user avatar

dev_in_progressdev_in_progress

2,4542 gold badges22 silver badges32 bronze badges

1

It May is not be relevant to this case, but:

I got this error when I change the Explicit type argument List of:

new ParameterizedTypeReference<List<SomeDtoObject>>()

to <> :

new ParameterizedTypeReference<>()

in restTemplate call after Intellij gave the warning to use <> instead.

It got fixed when I undo my changes back into the Explicit type argument.

answered May 3, 2022 at 18:00

Jay Ehsaniara's user avatar

Changing the Language Level in the Project Settings (Ctrl + Alt + Shift + S) to Java 8 solved the problem for me

answered Jul 27, 2018 at 7:52

Chris K.'s user avatar

Chris K.Chris K.

1,0508 silver badges10 bronze badges

I had the same problem. I fixed changing my settings. Target bytecode version for equals Project bytecode version.

enter image description here

answered Jun 15, 2020 at 21:30

Thiago de Melo Fontana's user avatar

What worked for me is to update the Open JDK version

answered Jun 17, 2020 at 11:26

NobuhleM's user avatar

I got the same error with Community edition 2020.3 on Windows 10 with an older version of the JDK (openjdk version «11» 2018-09-25).

Updating the JDK to javac 11.0.10 fixed the issue.

Here’s the stack trace that showed up with the error when using openjdk version «11» 2018-09-25:

java: compiler message file broken: key=compiler.misc.msg.bug arguments=11, {1}, {2}, {3}, {4}, {5}, {6}, {7}
java: java.lang.AssertionError
java:   at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
java:   at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
java:   at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$2$1.setOverloadKind(DeferredAttr.java:172)
java:   at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.visitReference(ArgumentAttr.java:283)
java:   at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMemberReference.accept(JCTree.java:2190)
java:   at jdk.compiler/com.sun.tools.javac.comp.ArgumentAttr.attribArg(ArgumentAttr.java:197)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:653)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.attribArgs(Attr.java:751)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1997)
java:   at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1634)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:655)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3573)
java:   at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2110)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.visitApply(Attr.java:2006)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.visitReturn(Attr.java:1866)
java:   at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1546)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:724)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:743)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1294)
java:   at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1020)
java:   at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:498)
java:   at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculative(DeferredAttr.java:481)
java:   at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr.attribSpeculativeLambda(DeferredAttr.java:456)
java:   at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode$StructuralStuckChecker.canLambdaBodyCompleteNormally(DeferredAttr.java:900)
java:   at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode$StructuralStuckChecker.visitLambda(DeferredAttr.java:878)
java:   at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCLambda.accept(JCTree.java:1807)
java:   at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode$StructuralStuckChecker.complete(DeferredAttr.java:832)
java:   at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:335)
java:   at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode.process(DeferredAttr.java:779)
java:   at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrContext.complete(DeferredAttr.java:626)
java:   at jdk.compiler/com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:214)
java:   at jdk.compiler/com.sun.tools.javac.comp.Resolve.rawInstantiate(Resolve.java:605)
java:   at jdk.compiler/com.sun.tools.javac.comp.Resolve.selectBest(Resolve.java:1563)
java:   at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethodInScope(Resolve.java:1733)
java:   at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1802)
java:   at jdk.compiler/com.sun.tools.javac.comp.Resolve.findMethod(Resolve.java:1776)
java:   at jdk.compiler/com.sun.tools.javac.comp.Resolve$10.doLookup(Resolve.java:2654)
java:   at jdk.compiler/com.sun.tools.javac.comp.Resolve$BasicLookupHelper.lookup(Resolve.java:3293)
java:   at jdk.compiler/com.sun.tools.javac.comp.Resolve.lookupMethod(Resolve.java:3543)
java:   at jdk.compiler/com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2651)
java:   at jdk.compiler/com.sun.tools.javac.comp.Resolve.resolveQualifiedMethod(Resolve.java:2645)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.selectSym(Attr.java:3721)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3601)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2598)
java:   at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$4.complete(DeferredAttr.java:374)
java:   at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredType.check(DeferredAttr.java:321)
java:   at jdk.compiler/com.sun.tools.javac.comp.Resolve$MethodResultInfo.check(Resolve.java:1060)
java:   at jdk.compiler/com.sun.tools.javac.comp.Resolve$4.checkArg(Resolve.java:887)
java:   at jdk.compiler/com.sun.tools.javac.comp.Resolve$AbstractMethodCheck.argumentsAcceptable(Resolve.java:775)
java:   at jdk.compiler/com.sun.tools.javac.comp.Resolve$4.argumentsAcceptable(Resolve.java:896)
java:   at jdk.compiler/com.sun.tools.javac.comp.Infer.instantiateMethod(Infer.java:181)
java:   at jdk.compiler/com.sun.tools.javac.comp.Resolve.checkMethod(Resolve.java:644)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.checkMethod(Attr.java:4120)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.checkIdInternal(Attr.java:3913)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.checkMethodIdInternal(Attr.java:3814)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.checkId(Attr.java:3803)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3696)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.visitLambda(Attr.java:2595)
java:   at jdk.compiler/com.sun.tools.javac.comp.DeferredAttr$DeferredAttrNode.process(DeferredAttr.java:811)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:3553)
java:   at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:2243)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:702)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.visitExec(Attr.java:1773)
java:   at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1452)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1098)
java:   at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:866)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4683)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4574)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4523)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4503)
java:   at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:4448)
java:   at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1341)
java:   at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:973)
java:   at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
java:   at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:147)
java:   at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
java:   at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
java:   at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:231)
java:   at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:501)
java:   at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:353)
java:   at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:277)
java:   at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:231)
java:   at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1441)
java:   at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1100)
java:   at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1224)
java:   at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:1066)
java:   at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:832)
java:   at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:419)
java:   at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:183)
java:   at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:132)
java:   at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:302)
java:   at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:132)
java:   at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:219)
java:   at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
java:   at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
java:   at java.base/java.lang.Thread.run(Thread.java:834)
java: Compilation failed: internal java compiler error
java: Errors occurred while compiling module 'project'
javac 11 was used to compile java sources
Finished, saving caches...
Compilation failed: errors: 1; warnings: 100

answered Apr 3, 2021 at 23:17

Pradyumna Revur's user avatar

enter image description here

Setting -> Build -> Compiler -> Java Compiler
The Target bytecode version of the module is wrong. I set it to 1.8, then it worked.

answered Jul 6, 2021 at 5:54

rosa's user avatar

rosarosa

713 bronze badges

In my case I had to go to help > show logs in files which opens up the idea.log and build-log folders something like

/home/user/.cache/JetBrains/IntelliJIdea2021.2/log/build-log/ where I set the log level to DEBUG in the log4j.rootLogger=debug, file in build-log.properties

I then ran build again and saw

2021-11-27 19:59:39,808 [ 133595]  DEBUG - s.incremental.java.JavaBuilder - Compiling chunk [module] with options: "-g -deprecation -encoding UTF-8 -source 11 -target 11 -s /home/user/project/target/generated-test-sources/test-annotations", mode=in-process
2021-11-27 19:59:41,082 [ 134869]  DEBUG - s.incremental.java.JavaBuilder - java:ERROR:Compilation failed: internal java compiler error

which lead me to see that this might me related to junit test compilation failing. It turns out I had an older/mismatching of the vintage engine and the jupiter engine which are likely to have different java versions relating in the error above. Changing them to be the same ${version.junit} removed the error.

  <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-launcher</artifactId>
            <version>1.6.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-commons</artifactId>
            <version>1.7.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${version.junit}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <version>${version.junit}</version>
            <scope>test</scope>
        </dependency>

In short some of your dependency jars may have mismatching java versions.

answered Nov 27, 2021 at 19:27

Gridcell Coder's user avatar

1

Was facing the same issue with Java 11. Solved by changing language level

File -> Project Structure -> Project

Change «Language Level» to SDK Default

enter image description here

answered Aug 10, 2022 at 17:35

Harshvardhan Chittora's user avatar

Updated Java compiler to correct «Target bytecode version» which in my case is 8 :

enter image description here

answered May 6, 2021 at 10:25

blue-sky's user avatar

blue-skyblue-sky

50.9k146 gold badges414 silver badges721 bronze badges

one reason may be jdk version donot macth minimal version of your project.

answered Jul 16, 2021 at 3:41

user13243683's user avatar

1

Be aware of JDK-8177068 issue, which leads to internal error like

java.lang.NullPointerException
        at jdk.compiler/com.sun.tools.javac.comp.Flow$FlowAnalyzer.visitApply(Flow.java:1233)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1628)
        at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
        at jdk.compiler/com.sun.tools.javac.comp.Flow$BaseAnalyzer.scan(Flow.java:393)
        at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitExec(TreeScanner.java:213)
        ...

It was fixed in JDK 11.0.12 and JDK 14 b14, so upgrade helped.

answered Aug 10, 2021 at 12:52

Nikita Bosik's user avatar

Nikita BosikNikita Bosik

8371 gold badge14 silver badges20 bronze badges

I switched across to the cmd line mvn compile build and it showed a more meaningful error.

Fatal error compiling: error: invalid target release: 17 -> [Help 1]

Checking my JAVA_HOME it was set to 11. Once I adjust my project to use 11 as well I got past this and onto another error (which was solved separately).

answered Aug 22, 2022 at 10:57

Shane Gannon's user avatar

Shane GannonShane Gannon

6,1607 gold badges37 silver badges59 bronze badges

Otherwise you can remove .m2 folder. Try to reload project.

answered Oct 8, 2022 at 20:39

Ali Can's user avatar

1

In my case, I was using Spring Framework 6.0.0 and JDK 11 as the same time. This is not supported according to spring framework wiki. After I degraded the spring framework version to 5.3.24, it solved.

You can check your spring framework version in this way.
spring framework version

answered Dec 13, 2022 at 6:08

Jarvan Lee's user avatar

Понравилась статья? Поделить с друзьями:
  • Compilation error rtc was not declared in this scope
  • Compilation error redefinition of void setup
  • Compilation error python
  • Compilation error pinmode was not declared in this scope
  • Compilation error maven