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
Volguus
Mar 3, 2009

Volmarias posted:

You may wish to file a bug to eclipse.org about this.

and then install IntelliJ

The only advantage you can get by installing IntelliJ is that once you pay them a boatload of money you have a leg to stand on when you yell at them to fix their own bugs yesterday. With Eclipse the only thing you can do is to ask nicely.

Adbot
ADBOT LOVES YOU

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
The free version is just fine for Jaba

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

NinetySevenA posted:

I have a strange problem with Eclipse.
When I go to close the line where I create a Scanner, when I use the semicolon Eclipse will delete the ) on (System.in) so it end up looking like (System.in;
I showed it to my prof, and he has never seen it before either. Since Eclipse does give error messages, It doesn't usually get away from me, but it would be nice to not have to deal with every time.

Here is a .gif of what's happening:



Has anyone seen this before, and is there a solution?
It does it on both my laptop and my PC at home.

e: Still happens even without the space. Yep, that's a bug.

carry on then fucked around with this message at 16:55 on Nov 12, 2015

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

NinetySevenA posted:

I have a strange problem with Eclipse.
When I go to close the line where I create a Scanner, when I use the semicolon Eclipse will delete the ) on (System.in) so it end up looking like (System.in;
I showed it to my prof, and he has never seen it before either. Since Eclipse does give error messages, It doesn't usually get away from me, but it would be nice to not have to deal with every time.

Here is a .gif of what's happening:



Has anyone seen this before, and is there a solution?
It does it on both my laptop and my PC at home.

Wow that's hosed. At first I thought you were typing (System.in;) and I was gonna say well, that's weird behavior but just don't do that. But you're not, you're typing (system.in); and its deleting the paren. That's a bug for sure.

Honestly I have most of the automatic paren stuff in eclipse turned off. I don't mind typing them but the automatic stuff is too inconsistent, there's some weird behaviors in there.

pksage
Jul 2, 2009

You are an experience!
Make sure you're a good experience.
We're migrating our Web tools off of an old VM running JVM 1.6.0 onto a newer one running 1.7.0_79. One of our tools uses myBatis to generate large INSERT queries that are used as part of hourly data ETL. It's a MySQL server, and we're connecting through a JDBC javax.sql.DataSource. On the OLD server, with JVM 1.6, a series of inserts totaling ~10,000 rows only takes about 10 seconds, but on the NEW one it takes like 3 or 4 minutes! What the hell?

I've been looking into this issue for like 10+ hours this week, tweaking different dependencies/includes, and I have no loving idea. We only recently narrowed it down to the JVM itself, after many test cases on different VMs, different networks, and different Tomcat versions. What changed between JVM versions that would make a query slow down so much? :confused:

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
have you tried skipping straight to 1.8 instead

Sedro
Dec 31, 2008
So you can take a working application, change JAVA_HOME and it breaks? That's hard to believe

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
Is it using addBatch & executeBatch? Have you tried profiling with the different java versions to see what it's spending time doing?

Volguus
Mar 3, 2009
When behavior like this happened to me before (version X behaved one way, version Y was completely different) it was due to the fact that the lower version had a "bug" that I was unknowingly taking advantage of. Got fixed in the more recent versions, and my application was no longer behaving as expected.
To your problem, the only reason that comes to my mind for taking that long to insert that many queries would be that is doing each insert within a transaction, while before it was probably grouping all inserts in a transaction. Beginning and committing a transaction can take a long time. Are you controlling the transaction properly? Are you letting the JDK/libraries control that?

Other than that ... I have no other explanation.

Squashy Nipples
Aug 18, 2007

Digging up some old poo poo, because I've been too absorbed with work lately.

Zaphod42 posted:

Syntactic sugar is any little tricks of the programming language which let you do more with less and keep things really clean. Things like auto-boxing.

Interesting, once again I made up my own wonky definition; I thought that SS referred strictly to syntax short cuts that the developers put in just to make your life easier. Like concatenating Strings with the plus sign (stringOne + " " + stringTwo), instead of having to call the String.Concatenate Method multiple times.

I see your point, though. :)

Cicero posted:

I'm going to try teaching programming to a couple of friends. I'm an Android dev, so assuming this doesn't fail miserably, I'm gonna start with plain Java (command line + Notepad++) and then transition to Android Studio. Does anyone have any recommendations as far as books go?

I've been doing this for the last two months.

While the official Java Tutorial trail is great, it's dense, and hard to navigate. I like to use it in conjunction with this guy's tutorial, it often helps me understand a topic better when I've read BOTH treatments.
http://tutorials.jenkov.com/java/index.html

Also, I'm a big fan of the Sams Teach-yourself books. The "Java in 24 Hours" starts off REALLY slow if you already know how to program (it doesn't get into Objects until chapter 10!!!), but it gave me a lot of contextual information about how Java is used, and how it's evolved.
http://www.amazon.com/gp/product/0672337029

ExcessBLarg!
Sep 1, 2001

Squashy Nipples posted:

Interesting, once again I made up my own wonky definition; I thought that SS referred strictly to syntax short cuts that the developers put in just to make your life easier.
I think this is the definition. Or it should be.

By Zaphod's definition convenience methods would be considered syntactic sugar. Except they're actually methods and have nothing to do with syntax.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

I usually think of syntactic sugar as "another, easier/shorter way of doing something in the syntax of the language specifically." Isn't String concatenation (usually) just syntactic sugar for a StringBuilder, for instance?

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

carry on then posted:

I usually think of syntactic sugar as "another, easier/shorter way of doing something in the syntax of the language specifically." Isn't String concatenation (usually) just syntactic sugar for a StringBuilder, for instance?

Pretty much. Under the hood, string concatenation via + creates a StringBuilder from the first string, then appends the rest of the strings in that statement, then returns toString from that builder. That's why you see the typical low-end interview question of

quote:

Why is this wrong?
code:
public String getResultString(Set<String> resultSet) {
  String resultString = "";
  for (String result : resultSet) {
    resultString += result;
  }
  return resultString;
}

The reason is that for every iteration through that loop, you're creating a new StringBuilder out of the current value of resultString, instead of just creating one and constantly appending to it. In addition to being generally suboptimal, it can cause memory thrashing. For example, consider the case where resultSet contains a million strings of 10 chars. How large is the returned string, and how much memory did you just take up to get there?

Rather than making your own StringBuilder like a caveman, you let the language do the hard work for you. Similarly, foreach really just iterates over an Iteratable's Iterator, rather than having you do the CS freshman work of making that iterator yourself, or writing yet another for(int i = 0; i < foo.size(); i++). If you wrote the code to iterate over the iterator yourself, you'd likely end up with the same bytecode.

Volmarias fucked around with this message at 06:29 on Nov 16, 2015

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Volmarias posted:

If you wrote the code to iterate over the iterator yourself, you'd likely end up with the same bytecode.

See yeah, this is what I think of when it's syntactic sugar. An easier way to do a common syntactical operation in the code that just gets compiled down to the other way.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Is there a better way than this of matching objects to a group of known objects?

Java code:
// identify which retrieved task corresponds to each of our initial tasks
        Task matchesA1, matchesA2;
        if (preceding[0].equals(A1) && preceding[1].equals(A2)) {
            matchesA1 = preceding[0];
            matchesA2 = preceding[1];
        } else if (preceding[0].equals(A2) && preceding[1].equals(A1)){
            matchesA1 = preceding[1];
            matchesA2 = preceding[0];
        } else {
            fail("Tasks preceding root task don't match!");
            return;
        }
It's basically checking the two valid possibilities and assigning the objects to the relevant identifying variables, which is fine for a simple situation like this. Is there a more general idiom or some fancy library function for this kind of thing? Building a map and failing for collisions/misses and null values remaining at the end?

Data Graham
Dec 28, 2009

📈📊🍪😋



Squashy Nipples posted:

Also, I'm a big fan of the Sams Teach-yourself books. The "Java in 24 Hours" starts off REALLY slow if you already know how to program (it doesn't get into Objects until chapter 10!!!), but it gave me a lot of contextual information about how Java is used, and how it's evolved.
http://www.amazon.com/gp/product/0672337029

Sweet, glad to hear you like those :cheers:

Volguus
Mar 3, 2009

baka kaba posted:

Is there a better way than this of matching objects to a group of known objects?

Java code:
// identify which retrieved task corresponds to each of our initial tasks
        Task matchesA1, matchesA2;
        if (preceding[0].equals(A1) && preceding[1].equals(A2)) {
            matchesA1 = preceding[0];
            matchesA2 = preceding[1];
        } else if (preceding[0].equals(A2) && preceding[1].equals(A1)){
            matchesA1 = preceding[1];
            matchesA2 = preceding[0];
        } else {
            fail("Tasks preceding root task don't match!");
            return;
        }
It's basically checking the two valid possibilities and assigning the objects to the relevant identifying variables, which is fine for a simple situation like this. Is there a more general idiom or some fancy library function for this kind of thing? Building a map and failing for collisions/misses and null values remaining at the end?

Hmm, I'm not sure I understand the point of it. Here's what I understand:
matchesA1 becomes preceding[X] when preceding[X] equals A1.

Now ... if preceding[X] equals A1 why not just say: matchesA1 = A1? Or ... simply use A1. Since you call equals on them and since you assign one to the other, it must be true that matchesA1, preceding[X] and A1 are equivalent and even equal.

Or, if this is a unit test (presumably from the fail method), and just want to check if whatever you put in you got back, you can also do:

code:
        if (!preceding[0].equals(A1) && !preceding[1].equals(A1)) {
		            fail("Did not get A1 back");
        }
        if (!preceding[0].equals(A2) && !preceding[1].equals(A2)) {
		            fail("Did not get A2 back");
        }
//essentially just making sure that you got both A1 and A2.  Use A1 and A2 later for whatever you may need.

Squashy Nipples
Aug 18, 2007

Data Graham posted:

Sweet, glad to hear you like those :cheers:

Why, which one did you write?

Data Graham
Dec 28, 2009

📈📊🍪😋



Rather not say for :ninja: reasons, but I wrote a couple and tech edited several others.

No Java ones though.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Volguus posted:

Hmm, I'm not sure I understand the point of it. Here's what I understand:
matchesA1 becomes preceding[X] when preceding[X] equals A1.

Now ... if preceding[X] equals A1 why not just say: matchesA1 = A1? Or ... simply use A1. Since you call equals on them and since you assign one to the other, it must be true that matchesA1, preceding[X] and A1 are equivalent and even equal.

Or, if this is a unit test (presumably from the fail method), and just want to check if whatever you put in you got back, you can also do:

code:
        if (!preceding[0].equals(A1) && !preceding[1].equals(A1)) {
		            fail("Did not get A1 back");
        }
        if (!preceding[0].equals(A2) && !preceding[1].equals(A2)) {
		            fail("Did not get A2 back");
        }
//essentially just making sure that you got both A1 and A2.  Use A1 and A2 later for whatever you may need.

Yeah it's a unit test - basically I'm writing two different structures into a database and making sure I get the same two back, and I'm not assuming anything about the ordering so I need to match them to their appropriate source objects

There's a bit more after that (some assertions to make sure each object's related structure is correct - they each represent a different test case) which is why I'm assigning them to a variable, but I was just wondering about the matching problem really. The map idea seems like a good fit for larger collections, I was just wondering if there was a slick solution to it

The 'just use A1' thing is a good idea, but I'm checking things not covered by my equality test (they're nodes and I'm checking the tree, maybe this is a horror) which is why I want to keep the original around. Also Hamcrest is not a name I'm making friends with

baka kaba fucked around with this message at 22:49 on Nov 16, 2015

Volguus
Mar 3, 2009

baka kaba posted:

Yeah it's a unit test - basically I'm writing two different structures into a database and making sure I get the same two back, and I'm not assuming anything about the ordering so I need to match them to their appropriate source objects

There's a bit more after that (some assertions to make sure each object's related structure is correct - they each represent a different test case) which is why I'm assigning them to a variable, but I was just wondering about the matching problem really. The map idea seems like a good fit for larger collections, I was just wondering if there was a slick solution to it

The 'just use A1' thing is a good idea, but I'm checking things not covered by my equality test (they're nodes and I'm checking the tree, maybe this is a horror) which is why I want to keep the original around. Also Hamcrest is not a name I'm making friends with

If it's a unit test, horror or not it doesn't matter (...much), as long as you keep each test very small. Make 100 test methods if you need to, but each of them should test only one little thing. In setup put some values in, then in the test methods you can:
- get values, do i have one with id 1? cool, pass
- get values, do i have one with id 2? cool, pass
- get the value with id 1,does it have property X equals "Y"? pass
- get the value with id 2,does it have property X equals "Z"? pass
......
and so on and so forth.

And the test DB is a memory DB, therefore nothing remains in there. Clear it after each test if needed.

22 Eargesplitten
Oct 10, 2010



Has anyone used Google Web Tools? My Eclipse version is Mars, but the most recent version for the eclipse plugin Google has is Luna. Will that work? Do I need to change anything?

Zorro KingOfEngland
May 7, 2008

Do you mean Google Web Toolkit?

If so, I've never had issues using a newer version of eclipse with an older plugin.

I think where you'd run into issues is if you tried to use a newer plugin (GWT-Luna) with an older version of eclipse (Kepler).

22 Eargesplitten
Oct 10, 2010



Yep, sorry. That's what I was thinking of. Thanks. It seems like it's working with the older version of the toolkit, thankfully.

FieryBalrog
Apr 7, 2010
Grimey Drawer

baka kaba posted:

Yeah it's a unit test - basically I'm writing two different structures into a database and making sure I get the same two back, and I'm not assuming anything about the ordering so I need to match them to their appropriate source objects

There's a bit more after that (some assertions to make sure each object's related structure is correct - they each represent a different test case) which is why I'm assigning them to a variable, but I was just wondering about the matching problem really. The map idea seems like a good fit for larger collections, I was just wondering if there was a slick solution to it

The 'just use A1' thing is a good idea, but I'm checking things not covered by my equality test (they're nodes and I'm checking the tree, maybe this is a horror) which is why I want to keep the original around. Also Hamcrest is not a name I'm making friends with

Why not use Collections and do something like this
code:
Set<Object> returnSet; 
Set<Object> verificationSet;
//get the objects initialized & populated however
for (Object r : returnSet) {
  if (!verificationSet.contains(r)) {
    return false;
  }

  return true;
}
then once they are ready to check, iterate through the returnSet, ask the verificationSet if it contains that object, and exit the loop if it ever fails.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Volguus posted:

If it's a unit test, horror or not it doesn't matter (...much), as long as you keep each test very small. Make 100 test methods if you need to, but each of them should test only one little thing. In setup put some values in, then in the test methods you can:
- get values, do i have one with id 1? cool, pass
- get values, do i have one with id 2? cool, pass
- get the value with id 1,does it have property X equals "Y"? pass
- get the value with id 2,does it have property X equals "Z"? pass
......
and so on and so forth.

And the test DB is a memory DB, therefore nothing remains in there. Clear it after each test if needed.

Yeah it kinda is set up like that, I have a test to add stuff and get their IDs, and then try to pull those IDs back out. This is a test that goes deeper and checks other objects have been attached. I don't think it's doing too much for a single test, it's just getting two objects and checking each has the right structure - I just need to identify which is which first. I was just wondering about the matching problem


FieryBalrog posted:

Why not use Collections and do something like this
code:
Set<Object> returnSet; 
Set<Object> verificationSet;
//get the objects initialized & populated however
for (Object r : returnSet) {
  if (!verificationSet.contains(r)) {
    return false;
  }

  return true;
}
then once they are ready to check, iterate through the returnSet, ask the verificationSet if it contains that object, and exit the loop if it ever fails.

Well with Sets you can just do .equals() if they're meant to contain the same objects! But the point is matching the initial objects to the created ones so I can test each appropriately. I'd probably just do something with a map and make sure every entry is mapped to its equivalent (and only for existing entries) if it was a bigger bunch of objects, I was just curious if there's a library or a special collection or something that's suited to it. It's always good to look around and see what's hiding out there

FateFree
Nov 14, 2003

I have a web application where one of the requirements is to allow the main .css file to be changed through a UI (running a tomcat server). How can I go about doing this? Can I simply copy the contents into a textarea, and let them submit it back to a controller where I overwrite the original css file? I imagine the war would need to be exploded to do this, but are there any other reasons it might not work?

pigdog
Apr 23, 2004

by Smythe

FateFree posted:

I have a web application where one of the requirements is to allow the main .css file to be changed through a UI (running a tomcat server). How can I go about doing this? Can I simply copy the contents into a textarea, and let them submit it back to a controller where I overwrite the original css file? I imagine the war would need to be exploded to do this, but are there any other reasons it might not work?
Security. Is it a concrete .css file with a predefined name? Is the upload interface properly secured? Is there any accountability or rollback if someone uploads a crap .css and the site breaks?

Frankly I would fight against such requirement. All the components of the site should be under version control and the site ought to be built from what's submitted there. How else can you offer any guarantees (or just peace of mind) about things working if you don't know what's actually running in live?

Sedro
Dec 31, 2008

FateFree posted:

I have a web application where one of the requirements is to allow the main .css file to be changed through a UI (running a tomcat server). How can I go about doing this? Can I simply copy the contents into a textarea, and let them submit it back to a controller where I overwrite the original css file? I imagine the war would need to be exploded to do this, but are there any other reasons it might not work?
It's a dumb requirement, but no you don't modify the war. Store the modified css in your database/filesystem/wherever your application stores things, and serve the original file if the modified copy doesn't exist.

First you should figure out what's the actual requirement. "modify css through a UI" is not a requirement. What do they actually want?

Boz0r
Sep 7, 2006
The Rocketship in action.
How do you guys feel on using the super keyword for calling a method, even though the current class doesn't override the method?

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
I've never seen anyone do it before, and conceptually I'm not a huge fan of the idea. It's either entirely pointless (if no-one ever overrides that method in the future), or it's surprising to whoever does override that method later (because now the class has an inconsistent idea of what that method does).

What scenario are you considering?

Boz0r
Sep 7, 2006
The Rocketship in action.
Nothing specific, there was just someone who used it a bunch of times in some code I was bug fixing, and I thought it was dumb.

Volguus
Mar 3, 2009

FateFree posted:

I have a web application where one of the requirements is to allow the main .css file to be changed through a UI (running a tomcat server). How can I go about doing this? Can I simply copy the contents into a textarea, and let them submit it back to a controller where I overwrite the original css file? I imagine the war would need to be exploded to do this, but are there any other reasons it might not work?

What I would do would be to save the contents of what they're modifying in the database and just inject that into the page (after the real main.css has been loaded) into a style element. Then you don't have to worry about modifying anything on disk, and can even be injected on a per-user basis if anyone would want that.

FateFree
Nov 14, 2003

Sedro posted:

It's a dumb requirement, but no you don't modify the war. Store the modified css in your database/filesystem/wherever your application stores things, and serve the original file if the modified copy doesn't exist.

First you should figure out what's the actual requirement. "modify css through a UI" is not a requirement. What do they actually want?

They want an application that they can deploy on separate servers/databases for different clients and have a different look and feel for each one, meaning logo and color schemes. So I was basically going to build an admin area to let them upload the logos and change the color scheme. I can easily have a backup or revert to default if they hose it but the question is if I store it in the database, I doubt I would want to serve it up from the database each time right? Even if it was cached, I figured the better approach would be to modify the file on change so its served up semi-statically.

Edit - I guess another approach is to construct the css out of a jsp file and store the colors as simple properties in a db.

FateFree fucked around with this message at 13:54 on Nov 24, 2015

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Boz0r posted:

How do you guys feel on using the super keyword for calling a method, even though the current class doesn't override the method?

It's definitely a code smell; you typically only ever want to use that when overriding a method to call the parent implementation to get its behavior before adding your own. If you don't want a method to be overridden further, you should make it final. I can't think of any good reason to want to do this, except for maybe some weird introspection stuff.

Seeing a method call super for another method should set off big alarm bells, since it's explicitly ignoring behavior set by subclasses. If the person who wrote this didn't leave comments as to why, track them down if you can and ask what in the world they were thinking. Good odds are that they weren't.

Boz0r
Sep 7, 2006
The Rocketship in action.
Yeah, that person stopped before I got hired.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

Boz0r posted:

How do you guys feel on using the super keyword for calling a method, even though the current class doesn't override the method?

Its like using the this keyword on everything but worse.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
Edit: nm

TheresaJayne
Jul 1, 2011

Zaphod42 posted:

Its like using the this keyword on everything but worse.

At work if we don't add this. its a sonar violation and we are ordered to fix it. same with a default constructor that calls Super, because the client cant get that it is implicit.

Adbot
ADBOT LOVES YOU

EpicCareMadBitch
Dec 20, 2008
Does anyone have a recommendation of a book to learn java for a complete newbie?

EpicCareMadBitch fucked around with this message at 13:47 on Nov 27, 2015

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