Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.
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

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. Bertrand Russell

That all makes me feel pretty good. I don't feel like a Java expert at all (I only taught myself last year for Android development), but I feel like I have an ok understanding of at least half of the things mentioned in the previous few posts. Yay me.

I don't work in anything programming related, but out of curiosity, how much could someone make as a Java dev who understands as much as me?

RiceWine
Jan 27, 2008
I'm making a TCP based p2p program in java for a class.

To read/write, i'm using InputObjectStream and OutputObjectStream.

Is there a way to send/receive multiple types of objects through the socket?

Safe and Secure!
Jun 14, 2008

OFFICIAL SA THREAD RUINER
SPRING 2013
Did not know about weak references. Or soft or phantom references. Weak references sound extremely useful if you're doing a lot of work with Collections. I don't understand how a senior developer wouldn't be using them, or why I'm just hearing about them now. Thanks!

Safe and Secure! fucked around with this message at 02:25 on Jul 29, 2012

Thom Yorke raps
Nov 2, 2004


Safe and Secure! posted:

Let's say that I claimed in an interview that I was a Java wizard, and this set my interviewer off on a mission to ask me increasingly difficult questions about Java to if I was lying. What kinds of questions/topics would I be asked about?

Out of all the languages I've used, I've got by far the most experience and am most comfortable in Java, so I figured that it would be best to focus on improving the area I'm good at if I want to get the best job I can when I graduate this Spring. What knowledge separates good, highly-experienced Java-using software engineers from the rest?
In addition to the things previous posters have mentioned, you should check out ThreadLocal. It is pretty neat.

If I really wanted to stump someone, I would ask them to implement a singleton that is constructed when it is first requested, that has public static members, and does not synchronize on getInstace(). (hint: it's impossible)
But that's only if I was being an rear end in a top hat. In general I don't care if someone knows the minutiae of Java, cause it doesn't mean they can write code worth a crap.

Thermopyle posted:

That all makes me feel pretty good. I don't feel like a Java expert at all (I only taught myself last year for Android development), but I feel like I have an ok understanding of at least half of the things mentioned in the previous few posts. Yay me.

I don't work in anything programming related, but out of curiosity, how much could someone make as a Java dev who understands as much as me?

Understanding poo poo like that is worth roughly $0. Understanding all that stuff and knowing how to properly structure programs, lead product development, and in general get poo poo done would net you a lot of money as a senior lead.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Ranma posted:

If I really wanted to stump someone, I would ask them to implement a singleton that is constructed when it is first requested, that has public static members, and does not synchronize on getInstace(). (hint: it's impossible)

Nope, it's definitely possible.

Java code:
class Singleton {
	//Other static methods and stuff

	static Singleton getInstance() {
		return LazyHolder.instance;
	}

	private static class LazyHolder {
		static Singleton instance = new Singleton();
	}
}
The inner class lets you access other static members of the Singleton itself, while still using the class loader to ensure that initialization is only performed once, when getInstance() is first called.

Imazul
Sep 3, 2006

This was actually a lot more bearable than most of you made it out to be.

Safe and Secure! posted:

Let's say that I claimed in an interview that I was a Java wizard, and this set my interviewer off on a mission to ask me increasingly difficult questions about Java to if I was lying. What kinds of questions/topics would I be asked about?

Out of all the languages I've used, I've got by far the most experience and am most comfortable in Java, so I figured that it would be best to focus on improving the area I'm good at if I want to get the best job I can when I graduate this Spring. What knowledge separates good, highly-experienced Java-using software engineers from the rest?

If you say Java wizard then I will ask you general OCJP certification level stuff like how do you multi thread in java, what is the volatile keyword for, what type of collection would you use if you want to store sorted objects allowing duplicates, what is an anonymous class, how does garbage collection work in java and something like name me a java framework you worked with and what did you do with it.

Of course before that we use a very dumb question to filter most people; explain pass by value and pass by reference concepts applied to java.

Doctor w-rw-rw-
Jun 24, 2008

Ranma posted:

Understanding poo poo like that is worth roughly $0. Understanding all that stuff and knowing how to properly structure programs, lead product development, and in general get poo poo done would net you a lot of money as a senior lead.

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.

Thermopyle posted:

I don't work in anything programming related, but out of curiosity, how much could someone make as a Java dev who understands as much as me?

Probably a question for another thread, but location makes a difference, and I have no clue how experienced a developer you are. Upwards of $60k for sure, possibly $70k or $80k+. And I'm lowballing for the Bay Area (but then, higher Bay Area rent will easily make the difference).

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Jabor posted:

Nope, it's definitely possible.
Also you can do double-checked locking in Java 5, it's in Effective Java 2E. Pretty sure he knows what he's talking about.
The IBM article is under Java 4 and using a slightly different form.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

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.


Probably a question for another thread, but location makes a difference, and I have no clue how experienced a developer you are. Upwards of $60k for sure, possibly $70k or $80k+. And I'm lowballing for the Bay Area (but then, higher Bay Area rent will easily make the difference).

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.

Thom Yorke raps
Nov 2, 2004


Jabor posted:

Nope, it's definitely possible.

Java code:
class Singleton {
	//Other static methods and stuff

	static Singleton getInstance() {
		return LazyHolder.instance;
	}

	private static class LazyHolder {
		static Singleton instance = new Singleton();
	}
}
The inner class lets you access other static members of the Singleton itself, while still using the class loader to ensure that initialization is only performed once, when getInstance() is first called.

:blush: awesome! learned something new

Volguus
Mar 3, 2009

Jabor posted:

Nope, it's definitely possible.

Java code:
class Singleton {
	//Other static methods and stuff

	static Singleton getInstance() {
		return LazyHolder.instance;
	}

	private static class LazyHolder {
		static Singleton instance = new Singleton();
	}
}
The inner class lets you access other static members of the Singleton itself, while still using the class loader to ensure that initialization is only performed once, when getInstance() is first called.

If you have other static methods in your singleton, you're doing something wrong (really, they don't belong there, move them someplace else). Since the only static method should be getInstance(), there's no need for a LazyHolder. But, technically, there's nothing wrong with your code.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Aleksei Vasiliev posted:

Also you can do double-checked locking in Java 5, it's in Effective Java 2E. Pretty sure he knows what he's talking about.
The IBM article is under Java 4 and using a slightly different form.

Since you didn't mention it, Bloch says that the best way to do a Singleton is by extending Enum. :shepface:

Java code:
public enum Foo {
   INSTANCE;
}

Sedro
Dec 31, 2008

MEAT TREAT posted:

Since you didn't mention it, Bloch says that the best way to do a Singleton is by extending Enum. :shepface:

Java code:
public enum Foo {
   INSTANCE;
}
Because then you can create a singleton factory
Java code:
public static <T extends Enum<T>> T getInstance(Class<T> clazz) {
    return (T)Enum.getValue(clazz, "INSTANCE");
}

Sedro fucked around with this message at 06:08 on Jul 30, 2012

Doctor w-rw-rw-
Jun 24, 2008

trex eaterofcadrs posted:

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.

I was lowballing. It's more like 2-3 years if you're good than 4-5 years, in the Bay Area. I know people who make less and work in areas where cost of living is also much lower, so they enjoy a similar discretionary income level. But this isn't a programmer salary thread, this is a Java thread. Moving on...
---

Is anyone sad that Java 7+ improvements may never make it into Android, since the language is no longer especially "open"? Is Apache Harmony dead because of a legal reason, or just developer lack of motivation, because there's no open-source technology compatibility kit? Could an open-source suite of unit tests help (eventually, when it's comprehensive enough to be a credible test for completeness)?

Doctor w-rw-rw- fucked around with this message at 09:19 on Jul 30, 2012

Safe and Secure!
Jun 14, 2008

OFFICIAL SA THREAD RUINER
SPRING 2013
I was excited for Java 7 until I found that we still wouldn't be getting real closures.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. Bertrand Russell

Ranma posted:

Understanding poo poo like that is worth roughly $0. Understanding all that stuff and knowing how to properly structure programs, lead product development, and in general get poo poo done would net you a lot of money as a senior lead.

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.

Yep. Being self-taught, working in seclusion, and not being in the industry makes it hard to know what you're worth.

Thanks for the info...

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Thermopyle posted:

I don't work in anything programming related, but out of curiosity, how much could someone make as a Java dev who understands as much as me?

50-60k in Atlanta. 85-110k after 5 years.

Doctor w-rw-rw-
Jun 24, 2008

lamentable dustman posted:

50-60k in Atlanta. 85-110k after 5 years.

Welp, looks like salaries for Java programmers is sufficiently on-topic that others are still talking about it.

If you play your cards right, being new to the industry in the Bay Area, you can probably start at $80-90k as a junior software engineer, depending on how well you negotiate, how well you interview, who you work for, and possibly other circumstances. If you prove yourself, jump jobs with good timing, and gain the right kind of experience, you can be making $10-20k more than that in a year or two (aka: lucky as poo poo), then you'll want to stick around somewhere for a while and follow a track to go from software engineer to a normal software engineer, then become a senior software engineer.

On the other hand, you might also consider a different track, which is to build some recurring income from stuff you build and put out there, which will then give you the flexibility to choose a job that will teach you the most, which you can also enjoy, since your supplementary income might make the difference between not making ends meet and living very comfortably. It's a longer timeline, to be sure. but might be more satisfying.

Safe and Secure!
Jun 14, 2008

OFFICIAL SA THREAD RUINER
SPRING 2013
I just want to do whatever will look best on my resume for a couple of years before I run off to teach English in some other country for a couple years, so that I can find a job when I get back.

Thom Yorke raps
Nov 2, 2004


I hate Maven.
So, I have a project with a dependency tree that looks like this:
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ cloudmine-javasdk ---
[INFO] com.cloudmine.api:cloudmine-javasdk:jar:0.3-SNAPSHOT
[INFO] +- junit:junit:jar:4.10:compile
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.1:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.6.4:compile
[INFO] +- org.slf4j:slf4j-simple:jar:1.6.4:compile
[INFO] +- commons-io:commons-io:jar:2.3:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.0.0-RC2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-core:jar:2.0.0-RC2:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.0.0-RC2:compile
[INFO] +- joda-time:joda-time:jar:2.1:compile
[INFO] +- org.apache.httpcomponents:httpcore:jar:4.2.1:compile
[INFO] +- org.apache.httpcomponents:httpclient:jar:4.2.1:compile
[INFO] | \- commons-codec:commons-codec:jar:1.6:compile
[INFO] \- commons-logging:commons-logging:jar:1.1.1:compile

and I have another project that depends on that jar
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ coderunner-test ---
[INFO] com.bigcompany.snippets:coderunner-test:jar:0.0.1-SNAPSHOT
[INFO] +- com.cloudmine.api:cloudmine-javasdk:jar:0.3-SNAPSHOT:compile
[INFO] +- com.cloudmine:coderunner:jar:0.0.1-SNAPSHOT:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.6.4:compile
[INFO] \- org.slf4j:slf4j-simple:jar:1.6.4:compile

Notice that according to this javasdk has no transitive dependencies. I wouldn't be surprised if I'm just doing something stupid cause I never use Maven, but does anyone have an idea why it isn't resolving these transitive dependencies? Right now, unless I manually copy over the dependencies, the code fails at run time with a NoClassDefFoundError.
If it matters, cloudmine-javasdk was manually added using mvn install:install-file.

Volguus
Mar 3, 2009

Safe and Secure! posted:

I just want to do whatever will look best on my resume for a couple of years before I run off to teach English in some other country for a couple years, so that I can find a job when I get back.

In a couple of years new technologies, methodologies and other crap will appear out there that will make your current experience pretty worthless. Oracle will close source Java and will ask 100k to anyone to even look at it, assembler will be the new best technology, etc.

Don't work for your resume. Work for you.

Kruegel
Jan 7, 2004
BSBSBSBS TEH END

Ranma posted:

I hate Maven.
So, I have a project with a dependency tree that looks like this:
...maven crap...

Notice that according to this javasdk has no transitive dependencies. I wouldn't be surprised if I'm just doing something stupid cause I never use Maven, but does anyone have an idea why it isn't resolving these transitive dependencies? Right now, unless I manually copy over the dependencies, the code fails at run time with a NoClassDefFoundError.
If it matters, cloudmine-javasdk was manually added using mvn install:install-file.

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.

Sedro
Dec 31, 2008

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.
Did you run mvn install:install-file off the jar or the pom?

Thom Yorke raps
Nov 2, 2004


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.

Sedro posted:

Did you run mvn install:install-file off the jar or the pom?
I ran it off the jar, that makes perfect sense, thank you guys!

StabbinHobo
Oct 18, 2002

by Jeffrey of YOSPOS
is it ok to ask jvm tuning stuff here?

I'm having a thing where whenever permgen gets right around 70% full, cpu utilization goes nuts and everything gets ~5x slower. doesn't actually break, just slows way down.

I can increase permgen, I can restart more often, but does anyone know if this is a predictable affect of some jvm default and there's an option I can tune to help? I already have -XX:+CMSClassUnloadingEnabled enabled.

Also, is there any downside to doing something absurd like making permgen 4gb?

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.
Have you profiled the GC with jstat?

StabbinHobo
Oct 18, 2002

by Jeffrey of YOSPOS

trex eaterofcadrs posted:

Have you profiled the GC with jstat?

extensively. between me and three of the other guys we've probably spent a combined 50 hours starting at visualvm/visualgc

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.
Honestly that sounds like a bug. When the CPU spikes, can you tell if it's due to GC overhead?

StabbinHobo
Oct 18, 2002

by Jeffrey of YOSPOS

trex eaterofcadrs posted:

Honestly that sounds like a bug. When the CPU spikes, can you tell if it's due to GC overhead?

no, as in no I can't tell. I don't trust the graph in visualvm, and htop shows some erratic results I haven't found a pattern to. the only consistent pattern is when permgen gets to 70% full (which takes about 30 hot deploys) urls that used to respond in 25ms start responding in 100ms. only way to fix it is to kill the jvm and start a new one.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.
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.

StabbinHobo
Oct 18, 2002

by Jeffrey of YOSPOS

trex eaterofcadrs posted:

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.

thats the hopefully-productive yak shaving path we've started down

are there any good commandline/programatic ways to do it though? taking a several-gigs heap dump and downloading it to your laptop to futz around in the gui tools is gruelingly slow.

Good Will Punting
Aug 30, 2009

And as the curtain falls
Just know you did it all except lift weights
Super newbie Swing question for a dumb final project for a class I'm taking! I have two JButtons and I want to change the icon of button 'B' when I press button 'A'. Is there a way to access the icon property of button 'B' in the actionPerformed method of button A's ActionListener?

E: Nevermind, I'm dumb and figured out my question which opened up a few new ones that I may post. Schools are bad at teaching programming.

Good Will Punting fucked around with this message at 18:23 on Aug 12, 2012

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

StabbinHobo posted:

thats the hopefully-productive yak shaving path we've started down

are there any good commandline/programatic ways to do it though? taking a several-gigs heap dump and downloading it to your laptop to futz around in the gui tools is gruelingly slow.

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

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

So the last time I significantly touched Java at all was when I was 10, using some book about Java 1. I have other programming experience, but can anyone recommend a book for learning it (preferably a free ebook)? Specifically I'm interested in getting into Android development, but I want to start with just learning Java now.

Max Facetime
Apr 18, 2009

MeramJert posted:

So the last time I significantly touched Java at all was when I was 10, using some book about Java 1. I have other programming experience, but can anyone recommend a book for learning it (preferably a free ebook)? Specifically I'm interested in getting into Android development, but I want to start with just learning Java now.

I would actually go with learning Android development from the start. You can pick up the Java you need as you go along, the instructions are from Google so they are straightforward, you'll get pretty pictures on the screen in short order and you'll start to learn how to get the most out of a modern IDE for Android and Java development while skipping manually compiling your code and fumbling with classpaths. The UI APIs are also different so there's not much point in writing a lot of Swing if you don't intend to start writing desktop Java applications.

There's also the small caveat that Android is only at Java 6, not Java 7, and Java/Android are at a sort of legal impasse right now with Android not even using a regular JVM, so there's no telling when the latest stuff in Java 7 and up will start appearing in Android.

mister_gosh
May 24, 2002

How can I tell if a bug has been fixed in a Java version? The bug in question is this:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7080203

baquerd
Jul 2, 2007

by FactsAreUseless

mister_gosh posted:

How can I tell if a bug has been fixed in a Java version? The bug in question is this:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7080203

Well other than testing a version, see that "Release Fixed" field with a value of "8(b14)"?

mister_gosh
May 24, 2002

baquerd posted:

Well other than testing a version, see that "Release Fixed" field with a value of "8(b14)"?

Yes, I did see that, but for a serious-ish type regression like this, I would think it would have been patched into the major version. So Java 7 does not have the fix as far as I can tell.

Adbot
ADBOT LOVES YOU

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
Can't you just check for null || arr.length == 0 or is 0-len a valid condition?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply