Is critical SonarLint issue S1166 in my Java code a false positive or not?

SonarLint 1.0.0 for Eclipse flags a critical issue in my code and I can't see why and how to fix it. It really looks like a false positive to me—or am I missing something? import org.apache.log4j.Logger; [...] public final class Foo { private static final Logger logger = Logger.getLogger(Foo.class); [...] public static void foo() { MyCommand command = new MyCommand

SonarLint在我的Java代码中发出S1166错误是否为假?

Eclipse的SonarLint 1.0.0标志着我的代码中的一个关键问题,我看不出为什么以及如何修复它。 这对我来说确实看起来像是一种误解 - 或者我错过了什么? import org.apache.log4j.Logger; [...] public final class Foo { private static final Logger logger = Logger.getLogger(Foo.class); [...] public static void foo() { MyCommand command = new MyCommand(foo, bar); try {

Hamcrest matcher comparing double value from JSON

I'm using the Hamcrest CoreMatcher classes as part of spring-test integration tests. My JSON looks like: {"data":[{"distanceInMiles":4,"id":"f97236ba-f4ef-4... And my integration test looks like: double miles = 4.0 Activity a = new BasicActivity(miles); this.activityManager.add(a); // A mock activity manager (in-memory) ... this.mockMvc.perform(get("/").accept("application/json")) .an

比较来自JSON的double值的Hamcrest匹配器

我使用Hamcrest CoreMatcher类作为spring-test集成测试的一部分。 我的JSON看起来像: {"data":[{"distanceInMiles":4,"id":"f97236ba-f4ef-4... 我的集成测试看起来像: double miles = 4.0 Activity a = new BasicActivity(miles); this.activityManager.add(a); // A mock activity manager (in-memory) ... this.mockMvc.perform(get("/").accept("application/json")) .andExpect(jsonPath("$.data[0].distanceInMil

How to make code modular?

I have some Java programs, now I want to find out whether it is modular or not, if it is modular then up to what extent, because modularity can never be binary term ie 0 or 1. How do I decide that particular code is modular upto this much extent. I want to know how to make code much more modular? Some Benchmarks for modularity: How many times are you rewriting similar code for doing a partic

如何使代码模块化?

我有一些Java程序,现在我想知道它是否是模块化的,如果它是模块化的,那么到什么程度,因为模块化不能是二元术语,即0或1.我如何确定特定的代码是模块化的达到这个程度。 我想知道如何使代码更加模块化? 一些模块化基准: 你有多少次重写类似的代码来完成特定的任务? 如果您在程序的某个部分更改了某些内容,您需要重构多少代码才能重构代码 ? 文件是否更小,更容易浏览? 应用程序模块在需要时是否充分独立运行

How to modularize a (large) Java App?

I have a rather large (several MLOC) application at hand that I'd like to split up into more maintainable separate parts. Currently the product is comprised of about 40 Eclipse projects, many of them having inter-dependencies. This alone makes a continuous build system unfeasible, because it would have to rebuild very much with each checkin. Is there a "best practice" way of how

如何模块化(大型)Java应用程序?

我手头有一个相当大的(几个MLOC)应用程序,我想将其分解为更易维护的独立部分。 目前该产品由大约40个Eclipse项目组成,其中许多项目具有相互依赖性。 仅凭这一点,连续构建系统就不可行,因为每次登记都需要重建。 有没有一种“最佳实践”的方法 识别可以立即分离的零件 可视化地记录相互依赖关系 解开现有的代码 处理“补丁”我们需要应用到库(目前通过将它们放入实际库之前的类路径中进行处理) 如果有(免费/开

JavaScript editor component to embed into java application

I have a largish application written in Java with a Swing UI. I am interesting in adding user scripting via JavaScript. To allow users to edit JS from within the application, I would like to go beyond a simple plain-text JEditorPane, with some kind of syntax-highlighting and smart indentation. The application is LGPL, so the license would need to be LGPL-compatible. I can use an old version

将JavaScript编辑器组件嵌入到Java应用程序中

我用一个Swing UI用Java编写了一个很大的应用程序。 我很有兴趣通过JavaScript添加用户脚本。 为了让用户能够从应用程序中编辑JS,我想要超越一个简单的纯文本JEditorPane,带有某种语法高亮和智能缩进。 该应用程序是LGPL,因此该许可证需要LGPL兼容。 我可以使用老版本的jedit-syntax(MIT许可证),但是我想知道是否有任何主动维护的项目可以做类似的工作,理想情况下可以通过Maven的方式进行。 我宁愿轻量级 - 没有Ecl

Write gui programatically, or using an advanced gui editor (Java Swing)?

I am planning to write a Swing-based application (using Netbeans 6.8). It seems that Netbeans has a very advanced GUI Editor... Still I have my doubts regarding the code generated by it. Additionally I don't like the fact the part of the code is locked (still I understand the need). Has anybody used Netbeans GUI Editor with success ? Does it "scale" ? Yes, the NetBeans GUI b

用编程方式编写gui,或者使用高级gui编辑器(Java Swing)?

我打算编写一个基于Swing的应用程序(使用Netbeans 6.8)。 看起来Netbeans有一个非常先进的GUI编辑器......但我仍然怀疑它生成的代码。 另外我不喜欢这部分代码被锁定的事实(我仍然理解需要)。 有人使用Netbeans GUI Editor成功了吗? 它是否“缩放”? 是的,NetBeans GUI构建器是最好的。 我对于它如何处理臭名昭着的GridBagLayout特别印象深刻。 Borland JBuilder在我的经验中是最好的往返GUI编辑器; 如果我没有

Tips for using Vim as a Java IDE?

I'm addicted to Vim, it's now my de facto way of editing text files. Being that it's mainly a text editor and not an IDE, has anyone got tricks for me to make it easier when developing Java apps? Some questions I have: How do I invoke a maven task without leaving vi? Can I get code completion? How's the syntax highlighting? Anything else (other than "Don't do

使用Vim作为Java IDE的提示?

我沉迷于Vim,现在它是我编辑文本文件的事实上的方式。 因为它主要是一个文本编辑器,而不是IDE,有没有人在开发Java应用程序时让我更容易些? 我有一些问题: 我如何在不离开vi的情况下调用Maven任务? 我可以完成代码吗? 语法高亮怎么样? 还有什么(除了“不要这样做!”),我应该知道吗? 一些技巧: 确保你使用vim(vi改进)。 Linux和一些版本的UNIX symlink vi到vim。 您可以使用eclim获得代码完成

mode with Java syntax highlighting?

I would like to use Emac's org mode for taking notes of java snippets. I would like the java snippets to be syntax highlighted. I tried running Org-mode in minor mode and Java-mode in major mode, but I found this lacks a lot of Org-Mode features (eg links). I would prefer to run Org-mode in major mode and have some minor mode to do java syntax highlihgting for when it finds java syntax.

Java语法突出显示的模式?

我想使用Emac的组织模式记录java代码片段。 我希望将java片段突出显示为语法。 我尝试在主要模式下以次要模式运行组织模式和Java模式,但我发现它缺少很多组织模式功能(例如链接)。 我希望在主要模式下运行组织模式,并且在发现java语法时有一些小模式可以为java语法highlihgting。 我宁愿避免#+ begin_src业务,因为我的文件将充满这些。 这可能吗? [编辑]正在思考没有标题和非组织标题的软语法突出显示。 即一

How to implement simple MVCC datastructure

I am reading about different concurrency models and different features of concurrency, but no text talks about how to implement a simple MVCC data structure. Let us say I have to implement a simple Array based data structure which provided MVCC based concurrency. How should my code look like? I understand that MVCC basically means: (Multiversion concurrency control) 1) Read isolation - your

如何实现简单的MVCC数据结构

我正在阅读有关不同的并发模型和并发性的不同功能,但没有文字介绍如何实现简单的MVCC数据结构。 让我们说我必须实现一个简单的基于数组的结构,它提供了基于MVCC的并发性。 我的代码应该如何? 我明白,MVCC基本上意味着:(多重并发控制) 1)读取隔离 - 您的写入不应该阻止读取 2)基于时间戳的订单建立发生在关系/订购之前。 我需要记住其他方面吗? 另外,我的下面的代码处理第一个要求,但如何实现时间戳排序?

Java Regex Matcher IllegalStateException

I am trying to use a matcher and am getting an IllegalStateException: no matches problem public static final Pattern PATTERN= Pattern.compile("(\d+)(\|)(\d+)((\*)(\d+)(\|)(\d+))?"); I then use it on the following input string Matcher matcher = PATTERN.matcher("20150220|10"); According to RegexPlanet, this should match the pattern: http://www.regexplanet.com/advanced/java/index.html Basica

Java正则表达式匹配IllegalStateException

我正在尝试使用匹配器,并得到一个IllegalStateException:没有匹配问题 public static final Pattern PATTERN= Pattern.compile("(\d+)(\|)(\d+)((\*)(\d+)(\|)(\d+))?"); 然后我在下面的输入字符串上使用它 Matcher matcher = PATTERN.matcher("20150220|10"); 根据RegexPlanet,这应该符合以下模式: http://www.regexplanet.com/advanced/java/index.html 基本上我的模式应该匹配以下两个字符串: "20150120|10" AND