Executive Summary: When assertion errors are thrown in the threads, the unit test doesn't die. This makes sense, since one thread shouldn't be allowed to crash another thread. The question is how do I either 1) make the whole test fail when the first of the helper threads crashes or 2) loop through and determine the state of each thread ...
I have a bunch of generic interfaces and classes
public interface IElement {
// omited
}
class Element implements IElement {
// omited
}
public interface IElementList<E extends IElement> extends Iterable {
public Iterator<E> iterator();
}
class ElementList implements IElementList<Element> {
public Iterator<Element> iterator(...
I have a class which looks something like this:
public class Test {
private static final Object someObject = new Object();
public void doSomething()
{
synchronized (someObject) {
System.out.println(someObject.toString());
}
}
}
Can I consider the object to be synchronized, or is there a problem since it is a static member?
Edi...
I have a class which constructor takes a Jakarta enums. I'm trying to find how I can easily inject it via an Spring XML aplicationContext.
For example :
The enum :
public class MyEnum extends org.apache.commons.lang.enums.Enum {
public static final MyEnum MY_FIRST_VALUE = new MyEnum("MyFirstValue");
public static final MyEnum ...
I am trying to implement performance testing on ActiveMQ, so have setup a basic producer and consumer to send and receive messages across a queue. I have created a producer with no problems, getting it to write a specific number of messages to the queue:
for(int i = 0; i < numberOfMessages; i++){
try{
String messag...
If you have a situation where you need to know where a boolean value wasn't set (for example if that unset value should inherit from a parent value) the Java boolean primitive (and the equivalent in other languages) is clearly not adequate.
What's the best practice to achieve this? Define a new simple class that is capable of expressin...
Is it possible to have a post-mortem ( or post-exception ) debugging session in Java ? What would the workarounds be ( if there isn't a solution for this already ) ?
...
Title says it all.
How do you do it, or is it even possible?
I suppose you could fiddle with getCanonicalWhatever and the original path, but that's messy and I don't like it. Please include a definitive reason if you suggest it.
...
I'm building a JSF+Facelets web app, one piece of which is a method that scans a directory every so often and indexes any changes. This method is part of a bean which is in application scope. I have built a subclass of TimerTask to call the method every X milliseconds. My problem is getting the bean initialized. I can reference the b...
I'm pretty sure that I'm not understanding something about JPA (I'm using OpenJPA) and it's causing this problem. I want to make a copy of a Job entity.
@Entity
@Table(name="Job")
public class Job implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
@ManyToOne
private Job ...
I'm wondering if I'm missing something about Java Beans. I like my objects to do as much initialization in the constructor as possible and have a minimum number of mutators. Beans seem to go directly against this and generally feel clunky. What capabilities am I missing out on by not building my objects as Beans?
...
I've got Postscript code/data (?) in memory (in a Java Tomcat webapp) that I'd like to send directly to a networked PS printer. Is there an easy way (i.e. just popping open a port and sending the text) to print this, bypassing all of the O/S-specific drivers and stuff (and hopefully not even requiring extra jars)? A link to example cod...
Here is the code currently used.
public String getStringFromDoc(org.w3c.dom.Document doc) {
try
{
DOMSource domSource = new DOMSource(doc);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
TransformerFactory tf = TransformerFactory.ne...
How do I extract a tar (or tar.gz, or tar.bz2) file in Java?
...
What's your opinion on whether one should write an application for a specific platform or use a cross platform approach and reach more potential clients?
It would be a GUI based application and I'm thinking of using Java.
Most of the applications that I've used built on Java don't run as smooth as the native applications on the respect...
What books would you guys recommend if one has been a java developer for years and is now trying to take the c#/asp.net route?
...
I saw this piece of code somewhere and wondered: when and why would somebody do the following:
doSomething( (MyClass) null );
Have you ever done this? Could you please share your experience?
...
Possible Duplicate:
Which Programming Language Should I Learn?
So I recently just finished a year of Java in my Computer Science class, and want to further pursue programming. I was not much thrilled about Java, I liked the OOP part but disliked its execution speed.
I was thinking C++ but I keep hearing people complain (?) ab...
In Java, you can qualify local variables and method parameters with the final keyword.
public static void foo(final int x) {
final String qwerty = "bar";
}
Doing so results in not being able to reassign x and qwerty in the body of the method.
This practice nudges your code in the direction of immutability which is generally consid...
I'm a relatively new convert to Python. I've written some code to grab/graph data from various sources to automate some weekly reports and forecasts. I've been intrigued by the Jython concept, and would like to port some Python code that I've written to Jython. In order to do this quickly, I need a NumPy clone for Jython (or Java). I...