43 Commits

Author SHA1 Message Date
Alexander Udalov 621fe41b17 JVM: restore incorrect DFS logic in JavaModuleGraph for compatibility
The problem is tracked in KT-66622. It should be fixed later, with a
proper deprecation, because otherwise it can potentially break a lot of
code.
2024-03-19 15:51:01 +00:00
Alexander Udalov 94e5cafb61 JVM: fix "module reads" check in JavaModuleGraph
There was a bug in the DFS. Whenever we encountered a "requires
transitive X" directive in some module, we recursively invoked DFS not
on X but on `dependencyName`, which is the target module that we're
trying to find the path to. And that always failed, because no module
requires itself.

 #KT-66275 Fixed
2024-03-19 15:51:01 +00:00
Alexander Udalov 5ca7ab9801 K2 JVM: implement Java modules-related checkers
All existing tests use custom test data for FIR because the diagnostic
text in FIR has to have a dot at the end. Also, the K2 checker doesn't
check usages in imports because there are no "import checkers" in K2
right now, this will need to be fixed later if necessary.

 #KT-60797 Fixed
2024-02-21 14:10:44 +00:00
Alexander Udalov ac901c6d07 Minor, improve test on unexported package in Java module
Add Kotlin class/function/property.
2024-02-21 14:10:44 +00:00
Kirill Rakhman f231338cd6 [FIR] Render list of symbols with linebreaks as separators
#KT-61823 Fixed
2024-02-21 12:25:22 +00:00
Alexander Udalov cdcb65c749 Tests: minor, slightly move JDK path substitution logic
It will be used in other CLI tests in subsequent commits.
2024-02-19 11:44:58 +00:00
Alexander Udalov 9fcf6c5f89 JVM: add tests on some JPMS-related diagnostics
Somehow we ended up in the state where we have two diagnostics which are
not covered by any tests in the project. This commit adds simple tests
for them.

 #KT-60797
2024-02-09 18:06:02 +00:00
Evgeniy.Zhelenskiy 7eab4b672d [K1, K2, CLI] Mark whole position range of compiler diagnostics in CLI
#KT-64989
2024-02-08 12:59:31 +00:00
Kirill Rakhman 1c446151e7 [FIR] Skip resolvable package names in front of UNRESOLVED_REFERENCE
#KT-55471
2023-09-04 08:05:08 +00:00
Kirill Rakhman d0cc86f52c [Tests] Update test data after changes to FIR diagnostic messages 2023-08-21 16:28:48 +00:00
Kirill Rakhman 5b9c35de2e [Tests] Update test data with error suppression warnings
#KT-61129 Fixed
2023-08-18 13:29:20 +00:00
Alexander Udalov 4e706ba93e K2: add JavaModulesIntegrationTest
#KT-60797
2023-08-14 16:32:15 +00:00
Mikhael Bogdanov 90f8f8e14e Support inner classes in -Xjdk-release
#KT-52823 Fixed
2022-08-02 04:56:20 +00:00
Alexander Udalov 7952e8b28f Add JVM target bytecode version 18
#KT-51309 Fixed
2022-02-14 21:21:57 +01:00
Mikhael Bogdanov 92e893bebe Rework Tune module graph dependencies building
#KT-50701 In progress
2022-01-14 11:22:46 +00:00
Mikhael Bogdanov faa2a67180 Add Java17ModulesIntegrationTest tests, fix problem with wrong diagnostic 2021-12-23 07:26:03 +00:00
Mikhael Bogdanov 78597912c0 Update tests for Java modules to be compatible with JDK 17 2021-12-23 07:26:02 +00:00
Mikhael Bogdanov a6052dce44 -Xjdk-release. Review fixes 2021-12-23 07:26:01 +00:00
Mikhael Bogdanov 6379ed22d1 Calculate proper roots for JDK 10-11
#KT-29974
2021-12-23 07:25:59 +00:00
Mikhael Bogdanov a062eb04ac Release flag. Check conflicts with `-jvm-target' 2021-12-23 07:25:59 +00:00
Mikhael Bogdanov c2d17ded33 Release flag. Add diagnostics 2021-12-23 07:25:58 +00:00
Alexander Udalov b8fb1ce83c Fix Java 9 module tests for many JDKs
Module 'oracle.desktop' is not guaranteed to be present in JDK. Also,
its usage in these tests doesn't check anything new that isn't already
checked by usages of jdk.net and jdk.httpserver.
2021-01-11 12:39:03 +01:00
Alexander Udalov b8d7b39e2c Extract Java 9 module test about irrelevant jars in JDK home
Skip it on JDKs where ant-javafx.jar is not present.
2021-01-11 12:39:03 +01:00
Alexander Udalov b10cc6657e Fix loading of builtins resources in kotlin-reflect in Java modular mode
The main change here is that when kotlin-reflect is being run under Java
9+, we use another implementation of BuiltInsResourceLoader (see
libraries/reflect/api/src/java9) which loads .kotlin_builtins files from
the java.lang.Module instance of kotlin-stdlib, instead of the class
loader of kotlin-reflect, which may not have access to those resources.

If the application is being run in the old (classpath) mode, that Module
represents the unnamed module, which contains everything on the
classpath, and everything works as before. But if it's being run in the
modular mode, that Module instance is an encapsulated module for
kotlin-stdlib classes and resources, exactly where .kotlin_builtins
files are located.

This fixes a regression in 1.4.0. Prior to 1.4, kotlin-reflect and
kotlin-stdlib were not named modules (see KT-21266) and were loaded as
_automatic_ modules even if the application was run in the modular mode.
Apparently, they shared the same class loader in that case and looking
up .kotlin_builtins resources worked.

This change was supposed to go alongside
828cc6dbf3, but was overlooked because
adding module-info to standard libraries was postponed at that point.

Also slightly refactor Java9ModulesIntegrationTest to simplify running
compiled code, and add a smoke test on using kotlin-reflect in modular
mode.

 #KT-40842 Fixed
2020-08-24 13:30:00 +02:00
Mikhail Zarechenskiy 319a38bd5c [NI-MIGRATE] Update diagnostic messages 2020-02-13 11:15:59 +03:00
Ilmir Usmanov 1336e8f3e3 Take java 9 modules into account in coroutines debug metadata
reading
 #KT-28237
2018-12-06 16:59:15 +03:00
Alexander Udalov e3a332c393 Configure Java module path when compiler is invoked in -Xbuild-file mode
#KT-27626 Fixed
2018-10-17 18:39:50 +02:00
Alexander Udalov 0439abba46 Check that kotlin.stdlib is explicitly required in module-info
Writing a Jigsaw-modular Kotlin program which doesn't require
kotlin.stdlib doesn't make sense because it most likely will fail at
runtime, on access to anything from the standard library. Previously, we
checked that kotlin.stdlib was in the module graph, but that's not
enough, we should also check that the source module requires it.
'-Xallow-kotlin-package' can be used to disable the error.

Add a test checking that an indirect (transitive) dependency is also OK
2018-04-03 21:50:25 +02:00
Alexander Udalov 828cc6dbf3 Add module-info.java for kotlin-reflect
The standard way of loading resources with built-ins metadata from the
current class loader no longer works in the modular mode on Java 9
because the current class loader is for module 'kotlin.reflect', but the
metadata is located in the module 'kotlin.stdlib'. On Java 9, we now use
the class loader of 'kotlin.stdlib' to load these resources.

 #KT-21266 Fixed
2018-04-03 21:24:03 +02:00
Alexander Udalov 897261a8a6 Add test on compiling against kotlin.reflect on JDK 9 2017-10-11 19:23:43 +03:00
Alexander Udalov 1592555783 Add test on compiling against kotlin.stdlib.jdk7/8 on JDK 9 2017-10-11 19:23:35 +03:00
Alexander Udalov 290deb6ba4 Minor, improve test on Java 9 modules
Test that unnamed module does not read unexported package of a named
module
2017-08-30 15:45:45 +03:00
Alexander Udalov 03a6488464 Use module path instead of class path for stdlib on Java 9
Also report the "named does not read unnamed" error, which was not
possible previously because we wouldn't be able to read anything from
kotlin-stdlib (because it was added to the unnamed module by default)
2017-07-10 12:48:21 +03:00
Alexander Udalov 158afdea2b Improve sorting of compiler messages in GroupingMessageCollector
Ensure that messages reported on a file but with no line information are
reported before diagnostics related to code. This fixes
Java9ModulesIntegrationTest.testSeveralModulesWithTheSameName on some
machines
2017-07-06 13:01:16 +03:00
Alexander Udalov 51fb02b2d5 Report warning for several modules with same name on module path 2017-07-06 13:01:13 +03:00
Alexander Udalov 9199023952 Improve automatic module handling in module graph construction
Add all automatic modules to roots if at least one automatic module is
added, as per
http://cr.openjdk.java.net/~mr/jigsaw/spec/api/java/lang/module/package-summary.html
2017-07-06 13:01:12 +03:00
Alexander Udalov c428505d4d Load automatic module names correctly
Load the Automatic-Module-Name manifest entry value if it's present (see
http://mail.openjdk.java.net/pipermail/jpms-spec-observers/2017-May/000877.html),
otherwise sanitize the name of the .jar file, throwing out all chars
except alphanumeric, duplicate dots and a version qualifier
2017-07-06 12:50:05 +03:00
Alexander Udalov 612e64d8e3 Load module-info.class from multi-release jars' META-INF/versions/ 2017-07-06 12:50:04 +03:00
Alexander Udalov 8c21ff66a4 Always treat all sources as parts of the module being compiled
If a path to the module-info.java file is passed as an argument, we
should treat all other source files passed as arguments (either as
individual source files or inside a source directory) as members of that
module. Previously we treated other source files as members of the
unnamed module, and this resulted in incorrect errors when using a
member exported with a qualification from another named module, for
example

 #KT-18598 In Fixed
2017-06-29 15:59:57 +03:00
Alexander Udalov 5192f946c5 Fix depth-first search for Java 9 modules
To compute modules to be added to compilation roots in
JavaModuleGraph.getAllDependencies, we should look not only for
transitive requirements of root modules, but for transitive requirements
of _root modules' requirements_. The same logic applies to
JavaModuleGraph.reads. In other words, when looking for a path in the
module graph between two modules, the first edge's transitiveness
doesn't matter, but all other edges after the first must be transitive.

There was also a stupid bug in dfs in
JavaModuleGraph.getAllDependencies: we continued the DFS only if the
module _was not_ added to the "visited" set ("add" returns true if the
element was added successfully)

 #KT-18598 In Progress
2017-06-29 15:59:57 +03:00
Alexander Udalov 72f37a278c Do not add all modules from module path when compiling unnamed module
Note that javac reports a nice error in this case ("package foo is
declared in module lib, which is not in the module graph"), but we only
report "unresolved reference" because the corresponding modules are not
added to classpath roots. We should improve this in the future

 #KT-18598 In Progress
2017-06-29 15:59:57 +03:00
Alexander Udalov 2d3888c710 Do not add JDK .jar roots if the JDK is modular (9+)
Files like ant-javafx.jar, deploy.jar, java.jnlp.jar, javafx-swt.jar etc
should not be added to the classpath if JDK home points to a JDK 9
distribution
2017-06-29 15:59:57 +03:00
Alexander Udalov 03d83db660 Support -Xmodule-path and -Xadd-modules command line arguments
#KT-18598 In Progress
 #KT-18599 Fixed
2017-06-29 15:59:56 +03:00