|
I'm having a strange problem with multicast sockets. After starting and stopping senders and receivers a few times, the receiver silently fails (no error, but never receives). The receiver shows up when I run netstat -bano. This happens on two Windows 7 machines.code:
code:
|
# ¿ Aug 17, 2011 17:01 |
|
|
# ¿ Apr 27, 2024 07:24 |
|
I figured it out (at least I haven't been able to reproduce the problem again). Apparently the receiver was picking a network interface at random. The fix was to modify the receiver from:code:
code:
|
# ¿ Aug 20, 2011 00:29 |
|
tractor fanatic posted:Why does transfer_wrong1 have a race condition? If you calculate the total balance of the accounts between the withdrawal and deposit, some money will have disappeared into the void.
|
# ¿ Sep 1, 2011 23:15 |
|
I mostly use this (and base, super, etc) when I want to filter autocompletion. Naming conventions like _fieldName solve the naming conficts (safer to avoid them entirely). There are some cases where it makes stylistic sense: code:
|
# ¿ Sep 3, 2011 05:20 |
|
Do whatever you want with private fields as far as I'm concerned. I would like to hear your reasoning against the typed equals method though.
|
# ¿ Sep 3, 2011 07:06 |
|
I would never write a typed equals without overriding object.equals and object.getHashCode. When I see a typed equals I immediately know that the type implements logical equality without looking at comments/source.
|
# ¿ Sep 3, 2011 16:31 |
|
It's important to follow Java naming conventions whether you like them or not. Beyond that, follow the convention used by the project. Java convention says not to prefix variables, so you're right - you'll have to use this. Curious, how do you guys differentiate interfaces vs implementations? code:
|
# ¿ Sep 3, 2011 18:14 |
|
Is there a way to make Netbeans or Maven raise errors/warnings for unchecked auto-unboxing? Currently this code doesn't raise a peep:code:
|
# ¿ Oct 6, 2011 20:39 |
|
I get warnings for null pointers in general, just not the specific unboxing case. This problem arose because I switched code generators and the new one loves boxed types. Now I have a bunch of NullPointerExceptions waiting to happen with no way to find them. I just switched IDEs after using eclipse for years because Netbeans' Maven + TomCat integration is so much better. I'm sure IntelliJ is great for standard Java development (I couldn't live without ReSharper). crazyfish posted:Have you tried a static analysis tool like FindBugs?
|
# ¿ Oct 8, 2011 00:04 |
|
You're comparing strings with the == operator which in Java compares object reference. You need to use equals instead:code:
|
# ¿ Oct 8, 2011 04:59 |
|
That's why I didn't bring up the indentation or redundant if clause
|
# ¿ Oct 8, 2011 05:51 |
|
Your problem is that neither of these statements are true:code:
code:
|
# ¿ Oct 8, 2011 06:58 |
|
Sab669 posted:I know there's a brief overview of a few IDEs on the first page, but I was hoping to get a little more information on Netbeans VS Eclipse. HFX posted:I would also say Eclipse has a git plugin that work.
|
# ¿ Nov 18, 2011 23:49 |
|
Try setting some of those values to temporary variables instead of using long conditionals. Then you can step through with a debugger and examine each value. It's also easier to read. To answer: selected.getDragArrowPoint() probably returns null, and you are dereferencing it. Also, if mousePosition.distance returns Integer, I think Java will automatically unbox it for the comparison and throw if the value is null. I'm sure someone will correct me though. Here's hoping for non-nullable reference types.
|
# ¿ Dec 17, 2011 06:18 |
|
I am in posted:Speaking of which, has anyone tried the Checker Framework and its Eclipse plugin? My biggest concern would be IDE integration. Horrible plugins for otherwise great tools tend to be a deal-breaker for me.
|
# ¿ Dec 18, 2011 02:23 |
|
Grawl posted:- can I get rid of that one final? Personally, I try to make all fields/variables/parameters final. I'm curious, does this have any impact on performance?
|
# ¿ Jan 14, 2012 01:53 |
|
Jabor posted:Assuming a sufficiently smart compiler (i.e. you're not developing for a Blackberry), I wouldn't think so.
|
# ¿ Jan 14, 2012 03:11 |
|
1337JiveTurkey posted:In that particular case I believe that the javac compiler will bake compile-time constants into any class that actually references it, so it's prohibited.
|
# ¿ Jan 14, 2012 06:11 |
|
You would appear to have two race conditions: A) Reference is dead initially, and gets GC'd between these calls: code:
code:
code:
|
# ¿ Feb 25, 2012 08:18 |
|
Crappy plugins drove me away from eclipse. In eclipse the build process was: 1. Make change 2. Maven build 3. Refresh all projects 4. Clean all projects 5. Clean maven 6. Clean web app 7. Clean TomCat working directory 8. Some other "clean" options I forgot? 9. Start server 10. Server didn't start? goto 2 11. Server started but I can't see the change at runtime? goto 2 After switching to netbeans: 1. Make change 2. Build and run They made the assumption that no third-party tool (including their own plugins) will ever modify the workspace. Since that's obviously not true, they added a million "clean" options to compensate.
|
# ¿ Mar 9, 2012 20:24 |
|
You should also mark the fields final so the compiler won't let you change them.
|
# ¿ Mar 12, 2012 00:26 |
|
There are methods on File to get the path string.
|
# ¿ Mar 13, 2012 21:54 |
|
The problem is in your code. Check whether randomYear is ever getting used.
|
# ¿ Mar 14, 2012 03:00 |
|
Read up on the difference between checked and unchecked exceptions.
|
# ¿ Mar 22, 2012 17:23 |
|
This doesn't actually do anything:code:
code:
Sedro fucked around with this message at 16:21 on Apr 16, 2012 |
# ¿ Apr 16, 2012 02:41 |
|
fletcher posted:At any rate, can somebody rip apart my method and tell me why it sucks? quote:The inner lists are sublist views of the original list, produced on demand using List.subList(int, int), and are subject to all the usual caveats about modification as explained in that API.
|
# ¿ Jun 29, 2012 00:33 |
|
Is there a way to create a file only if it doesn't exist, free of race conditions? I want this behavior: File exists -> throw exception File does not exist -> atomically create the file and increment usage count
|
# ¿ Jul 27, 2012 20:43 |
|
I am in posted:I don't know what usage count means in this context, but java.nio.file.Files.createFile(Path path, FileAttribute<?>... attrs) sounds like it would do that. That API appears to do what I want, but unfortunately I'm on Java 5 and unable to upgrade. (edit: actually it doesn't do what I want. For some reason I thought it returned a stream.) Edit: I want the standard behavior of the FileOutputStream and RandomAccessFile constructors, except I want an exception if the file already exists. I could use O_EXCL in Unix, FileMode.CreateNew in .NET, etc. I can't find Java support for this anywhere. Sedro fucked around with this message at 23:20 on Jul 27, 2012 |
# ¿ Jul 27, 2012 22:06 |
|
MEAT TREAT posted:Since you didn't mention it, Bloch says that the best way to do a Singleton is by extending Enum. Java code:
Sedro fucked around with this message at 06:08 on Jul 30, 2012 |
# ¿ Jul 30, 2012 06:06 |
|
Kruegel posted:I'm pretty sure the pom files tell maven what the dependencies are and since you probably just provided the jar file (and not the pom) for javasdk it has no clue what its dependencies are.
|
# ¿ Aug 4, 2012 01:29 |
|
fletcher posted:
You don't want to return an object which gives the caller power to mutate myObjects (requirement 1, be friendly to yourself). You also don't return an object which could surprise the caller by changing when they didn't expect it to (requirement 2, be friendly to the consumer). Method 1 fails requirements 1 and 2. Method 2 fails requirement 2. Method 3 doesn't compile. The easiest solution is to create a copy: Java code:
|
# ¿ Oct 11, 2012 22:59 |
|
The answer is covariance. In Java you use a "wildcard" with the syntax "? extends":Java code:
That's actually not true for a mutable list but Java will compile it: Java code:
|
# ¿ Dec 14, 2012 19:53 |
|
emanresu tnuocca posted:this method will check if objectToProcess is instanceof GameNode and if it is it will call a static method It sounds GameNode could be implemented as a composite. Java code:
Sedro fucked around with this message at 17:51 on Dec 16, 2012 |
# ¿ Dec 16, 2012 17:47 |
|
You can use IDE-based code generation, bytecode desugaring, or use Scala (or some other flavor of not Java).
|
# ¿ Jan 16, 2013 22:58 |
|
Internet Janitor posted:The designers of C# recognized how common this pattern was and provided Attributes to add syntactic sugar which makes it look like you have a public field but provides all the functionality of wrapping the field in methods.
|
# ¿ Feb 3, 2013 17:24 |
|
You have an off-by one: you will never defect more than once in a row.
|
# ¿ Feb 13, 2013 23:37 |
|
You could try ProGuard if your use-case permits.
|
# ¿ Mar 3, 2013 18:14 |
|
armorer posted:Your set up is extremely common for maven, and not really a problem. (Although your parent pom should NOT include dependencies on projects that reference the parent pom itself, that would create a screwy circular dependency and be problematic. It sounds like maybe you have done this? The parent pom should only specify other common dependencies, it should not depend on things that depend on it.) parent/pom.xml XML code:
XML code:
XML code:
|
# ¿ May 23, 2013 16:37 |
|
Yes, you would use the same version for each module and develop/release them as a single unit. Sometimes I don't need the granularity that Maven provides. For example, my application might reference a separate module containing binary resources (separated for reasons outside of maven), and the two artifacts must be deployed together.
|
# ¿ May 23, 2013 18:31 |
|
|
# ¿ Apr 27, 2024 07:24 |
|
I'm looking for something to administer processes distributed across servers. I want to add, remove, start, stop, and configure the processes from a central location. The processes themselves are implemented in Java (or something else which interfaces through Java), but some other communication mechanism like web services would also be fine. Mainly I want a nice UI (web based or thick client) which does all this administration without much integration work on my part. Any recommendations?
|
# ¿ Jun 7, 2013 18:26 |