|
In Java everything character and time related should accept a localization parameter, if one is not provided it defaults to the local computer's settings, which means that if you haven't added those parameters, the defaults might lead to different behavior.
|
# ¿ Apr 19, 2012 18:57 |
|
|
# ¿ May 9, 2024 05:58 |
|
Hidden Under a Hat posted:Could you give me an example of a "localization parameter"? Locale.US TimeZone.getTimeZone("GMT-8") Now if you're doing things with relative times that have NOTHING AT ALL to do with wall time or durations of Days/Weeks/Months/Years, then by all means, System.currentTimeMillis() (or nanoTime()) is probably ok for your usage.
|
# ¿ Apr 20, 2012 00:10 |
|
So what do you do with the time? If you do not care about wall time or durations of time longer than hours, you shouldn't even bother with Calendar and Date.
|
# ¿ Apr 20, 2012 15:13 |
|
Yeah not all days are 24 hours, leap seconds and DST changes will affect time.
|
# ¿ Apr 20, 2012 16:49 |
|
You make a good point. Time is such a complex and nuanced topic that, like I am in, I know enough to say I don't know poo poo, and I use weasel words a lot. That said, specifically about S.cTM: if you check the JavaDoc: http://docs.oracle.com/javase/6/docs/api/java/lang/System.html#currentTimeMillis() JDK SE 6 posted:Returns the current time in milliseconds. Note that while the unit of time of the return value is a millisecond, the granularity of the value depends on the underlying operating system and may be larger. For example, many operating systems measure time in units of tens of milliseconds. Now currentTimeMillis() is perfectly ok for many (most?) tasks, but you really need to understand your problem domain to know how timekeeping should be accomplished, and be well educated about the options and how your app needs to respond.
|
# ¿ Apr 20, 2012 18:07 |
|
At the risk of sounding like a broken record, have you looked at grails?
|
# ¿ Apr 23, 2012 02:36 |
|
For something like that I'd probably use Quartz: http://quartz-scheduler.org/
|
# ¿ Jun 28, 2012 22:13 |
|
baquerd posted:I've used Quartz but I don't see how it would make things more elegant? It seems like I would just be using a SimpleTrigger to execute a Job instead of a Timer to execute a TimerTask. Mostly to externalize the configuration and have an de facto industry standard component for task scheduling. More software engineering than development elegance, I suppose.
|
# ¿ Jun 28, 2012 22:48 |
|
Go here: http://docs.guava-libraries.googlecode.com/git-history/release/javadoc/index.html and look up Lists: http://docs.guava-libraries.googlecode.com/git-history/release/javadoc/com/google/common/collect/Lists.html there's a partition method. Use that. If you can't add another library to your code, then get it from git and put the guts of that method into yours.
|
# ¿ Jun 28, 2012 23:19 |
|
Have you profiled the app to find out if that's really what's going on?
|
# ¿ Jul 10, 2012 19:06 |
|
Hidden Under a Hat posted:Ok it's definitely the chart object, class instances of the Chart object keep going up even though there should only ever be one Chart object that keeps getting reinitialized. So what are some ways to ensure an object is dereferenced and destroyed? Sometimes (but not usually) a static analysis tool like FindBugs can uncover a situation where you're holding a reference that will prevent GC. Other than that, you have to look at the entire object lifecycle and audit the references to it. Something must be putting it in a collection or some other container that never goes out of scope.
|
# ¿ Jul 11, 2012 14:07 |
|
super.fn() simply calls the method "fn" on its superclass with the current object's data, if the superclass calls an overridden method, it will find the most specific override that matches E: I should probably be more clear. The type of the object does not change even when superclass methods are called, so the override will still be "in play" even in super methods. \/ yeah you did a way better job of explaining than I did trex eaterofcadrs fucked around with this message at 19:58 on Jul 12, 2012 |
# ¿ Jul 12, 2012 19:51 |
|
You could always try Google Protocol Buffers. It's a wire format but it should work fine.
|
# ¿ Jul 19, 2012 21:00 |
|
What's happening is that the TypeAdapter that GSON ends up using for your example is ReflectiveTypeAdapter, which is seeing the long value; field in the Example class, then tries to use a parser for Long which then craps out on that number. I'm not sure how you register new TypeAdapters but there is a List <TypeAdapterFactory> factories object inside GSON (Gson.class:120) that it looks for TypeAdapterFactory classes that support your class. It iterates through that List though (Gson.class:352) and once it finds a potential match it plows on ahead, which indicates to me that it'll be hard for you to fix this without using maybe BigDecimal instead of long. I did this based on the current SVN head so if you're using a different version obviously ymmv.
|
# ¿ Jul 21, 2012 21:12 |
|
Another way to do it is to literally count up all your class file sizes, including jars. It's a lot of stupid work and you need to be thorough, and that also doesn't include rt.jar or any runtime generated classes (say from Spring proxies or Hibernate proxies).
|
# ¿ Jul 25, 2012 21:13 |
|
MEAT TREAT posted:Just wanted to add that WebServices also love to chew through the permgen space when you redeploy them a lot. If this happens to you then you must have a ClassLoader leak, or a configuration where the jvm is not allowed to reclaim objects in permgen.
|
# ¿ Jul 26, 2012 13:54 |
|
Adding on to Internet Janitor and MEAT TREAT's ideas: * What autoboxing is * A pretty comprehensive understanding of the Collections framework (difference between Set, List, Map and their implementations), Iterator, etc. * Difference between long, int, double, float * What the heap and stack are * Difference between an Error and an Exception * If you really wanna bake them, ask about bytecode (what's the difference between invokestatic and invokevirtual, for instance) or JVM internals
|
# ¿ Jul 28, 2012 18:51 |
|
Doctor w-rw-rw- posted:I think he wasn't talking about the value of the skill itself, but rather how much someone with his level of experience might be able to market his skills for. In Chicago there's a ton of high profile Java firms and talent is thin, you could get near 100k here if you didn't suck and hung around for 4-5 years.
|
# ¿ Jul 30, 2012 01:41 |
|
Have you profiled the GC with jstat?
|
# ¿ Aug 6, 2012 16:55 |
|
Honestly that sounds like a bug. When the CPU spikes, can you tell if it's due to GC overhead?
|
# ¿ Aug 7, 2012 15:11 |
|
A little tangent; if permgen is filling up during hot deploys then the app has a ClassLoader leak. I wonder if that might have something to do with it. I'm totally taking a shot in the dark here but if you can track down the leak, your app will be better for it anyhow.
|
# ¿ Aug 10, 2012 14:04 |
|
StabbinHobo posted:thats the hopefully-productive yak shaving path we've started down Nothing automatic as far as I know but http://www.samaxes.com/2007/10/classloader-leaks-and-permgen-space/ is probably the most concise step by step I've found
|
# ¿ Aug 12, 2012 20:46 |
|
Safe and Secure! posted:While we're on the topic, any favorite Java mock libraries? Mocking really pisses me off but when I have to, I use Mockito.
|
# ¿ Aug 22, 2012 14:14 |
|
Well Java 7 will fix that stupid issue:code:
|
# ¿ Aug 30, 2012 19:14 |
|
rhag posted:I personally believe that the contract should be something like this: This is what I do unless I have Option types.
|
# ¿ Aug 31, 2012 15:05 |
|
You could use reflection, or write a compiler.
|
# ¿ Oct 26, 2012 13:51 |
|
I was going to say just hoist the Clojure collections, but this is probably the best answer.
|
# ¿ Mar 3, 2013 23:38 |
|
baquerd posted:Can someone point me in the direction of difficult problem sets dealing with low-level concurrency? I feel the need to brush up, having been spoiled with Spring and dealing with problems that don't care about approaching concurrency with a naive solution. As a related aside, I've had a copy of Java Concurrency in Practice for many years. One of the best ones I've seen is the one Rich Hickey demonstrated about an ant colony. Best links I can find are these: http://juliangamble.com/blog/2011/12/28/clojure-gui-demo-of-ants/ https://gist.github.com/jjcomer/1494094
|
# ¿ May 13, 2013 04:38 |
|
The first thing that came to mind for me was structure sharing. Maybe you can look at this library? It has a PersistentHashMap you can probably steal and repurpose. https://github.com/krukow/clj-ds My thoughts are, if the underlying CHM changes after the snapshot iterator is generated, the iterator's internal instance simply will not be aware of the modified entries, but all subsequent operations on the original CHM instance will be available for any other operations. You will likely have to do some wizardry to regain the full semantics of CHM but it shouldn't be too hard.
|
# ¿ May 18, 2013 00:44 |
|
Fly posted:Why does anyone use maven by choice? (serious question) There must be something it's good at doing. I use it because I also use OSGi and Maven makes deployment into the OSGi container vastly easier than just dumping dependencies in a hotfolder.
|
# ¿ Jun 25, 2013 04:00 |
|
Fly posted:edit: The dependency downloading is the one thing that gives me the most grief. What else does it do that might be useful? It gives you a very widely adopted standard to version your own artifacts. You can run your own nexus and personally vet any artifacts it provides if you want. I used to use it for large-scale internal development projects (SOA systems mostly) and it was a godsend. Just always use Maven 3. Maven 2 was a piece of poo poo from hell. Also deploying FROM a nexus is usually pretty drat simple, which is again what I use it for. I can say "install artifact com.example/poo poo-maker/2.0.1" and it'll go do it. It also has tons of plugins for doing lots of tedious poo poo. The only issue I have with them is that they are usually poorly documented (read the source) and the xml config for them can get wonky fast.
|
# ¿ Jun 25, 2013 04:22 |
|
Jabor posted:So how does it interact with your actual version control solution? Is it some separate entity that you have to keep in sync? Well, for the most part they're orthogonal. One is the versioning and control of source (which includes the pom.xml maven config file) and the other is versioning and control of build artifacts. Once you tag a version in source control, you can use your continuous integration tool to automatically deploy the build artifacts to maven. so my toolchain is like this hg tag $version -> hudson sees new tag and generates build $build_no -> build $build_no passes tests, artifact $version.jar generated -> artifact $version.jar deployed to internal maven nexus That said, Maven can also host source artifacts so you can have source up in the nexus with your jars and wars and whatever else.
|
# ¿ Jun 25, 2013 15:43 |
|
Hard NOP Life posted:In that case you can inspect your direct dependencies POMs to make sure they declared a single version of their dependencies. Again Artifactory and Nexus can help because you can overwrite their POM if it's wrong and they don't want to fix it. This is all true and also there's nothing stopping you from rebundling jars. I do this all the time because people don't make OSGi compatible bundles a lot of the time.
|
# ¿ Jun 26, 2013 01:52 |
|
supermikhail posted:If you can keep a secret, I had this as part of an idea of artificial evolution while commuting. /secret. I think it's deterministic, just not guaranteed in any given circumstance.
|
# ¿ Jul 30, 2013 22:03 |
|
rhag posted:When i had to inspect a lot of classes to make sure they behave (for other reasons than you), what I did was to write unit tests that would do the inspection for me. The tests would be run with each build, giving me very fast feedback on the status of the build. Yeah I actually was playing around with exactly how to do this last night. I didn't see a mechanism to get just the byte code bytearray for a specific method. I think the "easiest" way without trying to write some kind of huge java thing is to use javap to decompile each one of the stupid classes and see if there is a method with a byte position greater than (say) 62,000. Shouldn't be too hard to do with grep/awk.
|
# ¿ Aug 21, 2013 17:36 |
|
|
# ¿ May 9, 2024 05:58 |
|
HFX posted:I have to process a large number of text files that were originally written by some kind of Cobol program. Is this a COBOL master file or just a text output from some kind of log or extract? It may be possible to read in as byte delimited record fields. Do you have a few samples?
|
# ¿ Aug 21, 2013 18:43 |