I have experimented with several different static analyzers for Java, notably Findbugs and PMD.
I am looking for examples of other static analyzers that may be worth running on Java code.
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
public class Main implements Runnable {
private final CountDownLatch cdl1 = new CountDownLatch(NUM_THREADS);
private volatile int bar = 0;
private AtomicInteger count = new AtomicInteger(0);
private static final int NUM_THREADS = 25;
…
Are these two equivalent? In other words, are the ++ and -- operators atomic?
int i = 0;
return ++i;
AtomicInteger ai = new AtomicInteger(0);
return ai.incrementAndGet();
Certain programming languages require the frequent typing of awkward key combinations.
As an example, I find myself typing -> all the time when coding in PHP, which I find to be awkward.
Which programming languages force you to type irksome key combinations frequently?
What programming languages are a good choice for High Integrity Systems?
An example of a bad choice is Java as there is a considerable amount of code that is inaccessible to the programmer. I am looking for examples of strongly typed, block structured languages where the programmer is responsible for 100% of the code, and there is as little…
Take the PriorityQueue for example http://java.sun.com/j2se/1.5.0/docs/api/java/util/PriorityQueue.html#offer(E)
According to the Collection API entry
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collection.html the add method will often seek to ensure that an element exists within the Collection rather than adding duplicates. So my…
Using the return keyword in Java code will return execution to the last piece of calling code in the call stack. If object foo calls baz.bar(), the return keyword in the bar method will continue code execution in foo.
Let's say I have object foo that calls foofoo that calls foofoofoo in the above scenario, and foofoofoo calls baz.bar().…
The question pretty much says it all.
If I have a class Class A
public class A {
...
private List<String> keys;
...
}
And I want to select all A instances from the DataStore that have atleast one of a List of keys, is there a better way of doing it than this:
query = pm.newQuery(A.class);…
Classic example of a simple server:
class ThreadPerTaskSocketServer {
public static void main(String[] args) throws IOException {
ServerSocket socket = new ServerSocket(80);
while (true) {
final Socket connection = socket.accept();
Runnable task = new Runnable() {
…
Is it possible to prevent a user from editing the title of a node on the node edit screen?
One of the things I really detest about Drupal is the rigidity of the title & body field in each node.
Yes, the private member variable bar should be final right? But actually, in this instance, it is an atomic operation to simply read the value of an int. So is this technically thread safe?
class foo {
private int bar;
public foo(int bar) {
this.bar = bar;
}
public int getBar() {
…
I know that you can press shift+alt+j to insert an appropriate comment template for the current code block, but is there any way to let eclipse just go crazy and do a whole project like this?
UPDATE files
SET filepath = REPLACE(filepath, `sites/somedomain.com/files/`, `sites/someotherdomain.com/files/`);
I have a table called files with a field called filepath. MySQL returns this error: Unknown column 'sites/somedomain.com/files/' in 'field list'
Two tables:
table_a
-------
table_a_id: (primary, int)
table_b
-------
table_a_id: (index, int, from table_a)
table_b_value: (varchar)
A one to many relationship between table_a_id and table_b_value.
Given a query like this:
SELECT DISTINCT(table_a_id) FROM table_a
JOIN table_b ON…