Comments (6)
Original comment posted by [email protected] on 2012-09-11 at 09:06 PM
Shuffling to Eddie since I don't have time to take a careful look.
I'm quite concerned about the performance of re-reading the source file in the matches() method. We'll have to re-read any file containing a long literal, possibly many times. If we go this way, we'll need to performance profile and probably cache something.
Also, make sure your test case has some unicode characters before the matching literal, so char offset and byte offset can't be confused.
It would be a lot better if we can find some sneaky way to access this without going back to the source, though I bet the information is totally gone after parsing.
Owner: [email protected]
from error-prone.
Original comment posted by [email protected] on 2012-09-12 at 07:03 AM
Thanks for taking a look, Alex.
I share your concern, but looking at the object in the AST, it simply doesn't have the information needed. The JCLiteral object just knows its position in the source file, and its value as a long. It doesn't record know whether a suffix is present, let alone whether it's an 'L' or 'l'. It also don't record whether it's encoded as hex, or octal, or decimal, or whether there are underscores present (for Java 7) and whether the hex elements (a-f and the 'x' in 0x...) of it are upper or lower case. Unfortunately we need to somehow extract this from the source.
My belief (based on little evidence at the moment) is that the source code string is already probably cached - I assume this is why sourceFile.getCharContent() can return null. If this is indeed the case, would your objection go away?
from error-prone.
Original comment posted by [email protected] on 2012-09-12 at 07:36 AM
I've tried this out by running "mvn test".
The call SourceFile#getCharContent() is actually RegularFileObject#getCharContent(), which includes this at the top of the method:
CharBuffer cb = fileManager.getCachedContent(this);
Based on stepping through the code, this returns a non-null reference containing the cached source file data. This seems to indicate to me that this matcher isn't going to have to keep re-reading the source file.
from error-prone.
Original comment posted by [email protected] on 2012-09-12 at 06:10 PM
Yeah if the source is already cached, that's great. I imagined it might be, since the API gives you the CharSequence directly.
We'll still give it a performance check at some point before turning on generally. but I think it's a good check to enforce. It's never a bug, but it's trivial to fix and important for readability.
from error-prone.
Original comment posted by [email protected] on 2012-09-12 at 09:57 PM
FYI, JLS section 3.10.1 says of long literals, "The suffix L is preferred, because the letter l (ell) is often hard to distinguish from the digit 1 (one)." So I think we're justified in making this a compile error as long as it doesn't kill performance.
from error-prone.
Original comment posted by [email protected] on 2012-09-13 at 12:39 AM
(No comment entered for this change.)
Status: Fixed
from error-prone.
Related Issues (20)
- Var false possitives detected when NPE (via nullaway) detected
- Invalid severity could have explicit error message
- InvalidInlinteTag: @snippet javadoc false positive
- Crash in JUnitIncompatibleType HOT 4
- MultipleNullnessAnnotations inconsistent on nested class HOT 5
- An unhandled exception was thrown by the Error Prone static analysis plugin HOT 3
- MultipleNullnessAnnotations shouldn't consider Validation Annotations HOT 3
- class file for com.google.errorprone.annotations.RestrictedInheritance not found HOT 3
- java.lang.ClassCastException: class com.sun.tools.javac.tree.JCTree$JCBinary cannot be cast to class com.sun.source.tree.ParenthesizedTree (com.sun.tools.javac.tree.JCTree$JCBinary and com.sun.source.tree.ParenthesizedTree are in module jdk.compiler of loader 'app') HOT 1
- `@Immutable` does not recognize safe array handling HOT 3
- Error-prone patching cannot be used in bazel
- Crash with annotated nested types
- NPE with nested instanceof patterns
- [IllegalAccessError] An unhandled exception was thrown by the Error Prone static analysis plugin. HOT 2
- An unhandled exception was thrown by the Error Prone static analysis plugin. HOT 1
- SystemConsoleNull should consider the case where `System.console() == null` HOT 3
- StringCharset BugPattern summary is not helpful
- An unhandled exception was thrown by the Error Prone static analysis HOT 1
- Update JDK from 11 to 21 and errorprone breaks HOT 1
- ParameterName IndexOutOfBoundsException HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from error-prone.