Commit Graph

45 Commits

Author SHA1 Message Date
Tagir Valeev
aa6829d7c1 [java-tests] IDEA-333831 Separate mock JDK and JetBrains annotations for testing
Also: avoid manual mocking of Java 10 classes in StreamCollector10Inlining test, use mockJDK11 instead
Also: rewrite SliceTestCase and its inheritors to LightJavaCodeInsightFixtureTestCase, as annotations.jar is not included into project created by DaemonAnalyzerTestCase
Also: 'mutates' attribute of @Contract annotation is resolvable now, as we can use newer jetbrains-annotations library.
Also: documentation tests now don't generate links to JetBrains annotations, which corresponds to the actual behavior in production

GitOrigin-RevId: e460826893c1277cb2b78b18aae9d5aca97d8333
2023-10-05 11:24:29 +00:00
Tagir Valeev
7b359df0e1 [java-inference] Avoid -> new; pure contracts on methods returning Collection or Map
We assume that such methods return local object. However, we also assume that Collection/Map size is its field. But in fact, it may delegate to another collection

Fixes IDEA-266180 Constant conditions & exceptions false positive with Guava Lists

GitOrigin-RevId: ba6f76bd1b34b1b9503b4be1ce85119ba54f6b3e
2021-04-09 05:13:19 +00:00
Tagir Valeev
b4c69a9cec [java-inference] Failure contract inference improved
GitOrigin-RevId: 687b4c909c1d2ae67d519ec71899d52fa3e29434
2021-03-11 11:27:56 +00:00
Tagir Valeev
da4a1cc6a5 [java-analysis] Purity solver optimizations
1. Stop loading equations if the solution is definitely impure and return value is known
2. Replace "mutates" map with single value in MethodAnnotations

GitOrigin-RevId: 1fd25b97060b3f5a3c9ce3b22c24baa10d35a6f7
2021-02-05 10:51:47 +00:00
Tagir Valeev
c5c09c693a [java-analysis] Hard-code that Throwable.initCause is mutates_this
This allows contract inference for methods like AssertionError(Object) constructor.
Fixes IDEA-260003 A warning is shown when Optional.get is called even when Optional.isPresent is verified before

GitOrigin-RevId: 548008f5462b828e0346f089474182f59ec39bd1
2021-01-22 12:55:45 +00:00
Tagir Valeev
d17aa59d6d IDEA-237601 Infer mutation signature from the bytecode
GitOrigin-RevId: d3c47f6a35f948f65f5d447d8561044d7ec9ce23
2020-04-14 12:31:00 +00:00
Tagir Valeev
79cc904ff9 BytecodeAnalysis: infer @NotNull for static final fields (for now: non-branching clinit only)
Fixes IDEA-223861 Infer static field nullability from the bytecode

GitOrigin-RevId: 2ee3102df5677e567defbe849900769237a728bc
2019-10-02 10:07:03 +00:00
Tagir Valeev
5422868682 BytecodeAnalysisIntegrationTest: depend on exact versions of velocity and collections 2018-10-26 16:00:05 +07:00
nik
224d9ced70 update commons-collection (IDEA-198976) 2018-10-25 09:37:06 +03:00
Roman Shevchenko
e0589b585f [tests] migrates bytecode analysis tests to light test case
... and moves test data out of source code
2018-09-14 14:45:43 +02:00
Tagir Valeev
1aae19b0df BytecodeAnalysisIndex: support new/this/paramX contracts
IDEA-191302 Introduce new contract return values: this, new, paramX
2018-05-04 17:44:23 +07:00
Tagir Valeev
37a4a385ab BytecodeAnalysisIntegrationTest: add missing commons-collection annotations after moving velocity to maven
Before commons-collections was packed inside the velocity.jar and many classes were removed from there
2018-03-30 14:14:22 +07:00
Tagir Valeev
b144fc264e Purity inference: fix expected data (which was not updated due to non-invalidated local cache) 2018-01-19 10:22:28 +07:00
Tagir Valeev
1aa64e3da2 IDEA-185138 Bytecode purity inference: do not infer method as pure if it reads the volatile field 2018-01-18 17:57:51 +07:00
Tagir Valeev
b414748d24 BytecodeAnalysis: force purity of enum.ordinal() and array.clone() 2018-01-15 16:29:57 +07:00
Maxim.Mossienko
4d165172dd update testdata to reflect newer mock jdk 1.7 2017-06-13 15:09:42 +02:00
Tagir Valeev
82da560c31 Introduced AggressiveHardCodedPurity under registry key (IDEA-CR-21434)
New key = java.annotations.inference.aggressive.hardcoded.purity (true
by default). Implies purity for Object.toString(), Iterable.iterator(),
Iterator.hasNext() and this-changing Iterator.next(). Parameter-changing
 mode supported for hardcoded purity.
2017-05-30 17:38:23 +07:00
Tagir Valeev
97eaee737b BytecodeAnalysis refactoring: HKey and Key merged to EKey; hashing is encapsulated inside HMethod/Method pair 2017-05-30 13:17:05 +07:00
Tagir Valeev
60e8eb5948 PurityAnalysis: Object.toString hardcoded pure 2017-05-29 15:14:46 +07:00
Tagir Valeev
668fcdd985 PurityAnalysis: more native methods hardcoded 2017-05-25 15:22:20 +07:00
Tagir Valeev
5599cc543f BytecodeAnalysis: infer failing contracts; infer contracts for input boolean arguments; squash inferred contracts; refactoring 2017-05-24 11:49:05 +07:00
Tagir Valeev
871ef095bb PurityAnalysis: StringBuffer.toString is also hardcoded (used for string concatenation in older java versions) 2017-05-24 10:45:15 +07:00
Tagir Valeev
9f7b27a7cc BytecodeAnalysisIntegrationTest: expected annotations fixed (somehow these two were missing) 2017-05-18 14:40:57 +07:00
Tagir Valeev
c41245708f Bytecode analysis: purity inference improvement (also fixes IDEA-172989):
1. Lambda/method reference creation is pure
2. String concatenation is pure
3. Constructor which only modifies own fields (calls setters, etc.) is pure
4. Exception creation is pure
5. A few hardcoded native methods
2017-05-18 10:52:53 +07:00
Roman Shevchenko
c1e9f34a41 [java] improves resolve inside .class file 2016-06-06 15:30:39 +03:00
Ilya Klyuchnikov
00712ecdf5 new annotations 2015-12-30 13:22:42 +03:00
Ilya Klyuchnikov
414ec9db35 IDEA-145968: a change in test data 2015-10-12 15:00:23 +03:00
peter
4d76c50f69 add LinkedHashMap to mockJdk7 2015-10-06 15:27:44 +02:00
Ilya Klyuchnikov
7944b7a260 IDEA-145494: reformatting test data 2015-10-05 18:27:37 +03:00
Ilya Klyuchnikov
ac3ee3b425 IDEA-144129: support for inferred negated contracts 2015-09-25 15:01:31 +03:00
peter
e5d728e7a4 don't return inferred annotations that will be neglected anyway (e.g. on overrideable methods) 2014-12-03 17:40:04 +01:00
Ilya Klyuchnikov
2cec677727 Testing Inference of '@Contract(pure=true)' annotations: delta in test data 2014-10-16 08:51:38 +04:00
Ilya Klyuchnikov
582239346e bytecode analysis: no inference of "true|false->..." contracts 2014-10-01 17:50:41 +04:00
Ilya Klyuchnikov
e0f6567a5d bytecode analysis: test data delta
IDEA-129645
2014-09-25 17:01:49 +04:00
peter
70b03fb0f0 correct bytecode analysis test data 2014-09-16 17:34:57 +02:00
peter
e2ee62224c display hardcoded contracts on the gutter 2014-09-16 13:50:45 +02:00
Ilya Klyuchnikov
f28955f810 testing new @Nullable annotations 2014-09-01 17:51:25 +04:00
Ilya Klyuchnikov
44f95a9b26 testing inference of @Nullable annotations for parameters 2014-08-25 18:30:43 +04:00
Ilya Klyuchnikov
d4eb76a1c3 bytecode analysis: delta in testdata 2014-08-19 09:04:39 +04:00
Ilya Klyuchnikov
b6b6ea1880 bytecode analysis: lite persistent hashCode for Configuration
Also subtle bug with Configuration generalization was fixed - so, update in annotations.xml
2014-07-11 16:05:43 +04:00
Ilya Klyuchnikov
ce6450136f no contract annotation if method is already @NotNull 2014-07-10 10:35:49 +02:00
Ilya Klyuchnikov
6dd49cb404 update annotations after mockJDK update 2014-07-10 10:35:48 +02:00
Ilya Klyuchnikov
0db25e9166 arrays and primitive collections
(annotations.xml was changed because the order of graph construction was changed - this particular case is a tricky one with loop, exception and synchronization)
2014-07-10 10:35:46 +02:00
Ilya Klyuchnikov
658b710762 aligned with faba 2014-07-10 10:35:46 +02:00
Ilya Klyuchnikov
338481d263 Bytecode analysis tests 2014-07-10 10:35:43 +02:00