« first day (1474 days earlier)      last day (3460 days later) » 

12:17 AM
Yeah it is
 
fge
12:57 AM
0
Q: How would I print the JVM's system properties using Java 8 and lambdas?

fgeYou can obtain a Properties instance of the JVM properties using System.getProperties(); how would you go about using Java 8 code to print all properties to the console?

You have to start somewhere ;)
 
fge
1:47 AM
Meta question: even though I have sufficient rep to edit answers and/or questions directly, is there a way to suggest an edit to the original author instead?
 
 
1 hour later…
fge
3:06 AM
1
A: Comparing digits of integers

fgeUsing a Set<Integer> you can code this as such: public static boolean hasDistinctDigits(int number) { final Set<Integer> set = new HashSet<Integer>(); while (number > 0) { if (!set.add(number % 10)) return false; number /= 10; } return true; } You ...

The Java 8 example is a bona fide case of mental abuse :p
(that's a good example of using a method reference on a local variable though)
Hmm
That would be an interesting exercise: given an int, code an implementation of IntStream where elements are the digits in a given base (10 by default), in their order of appearance, or reverse order of appearance; remind to appropriately fill this stream's .characteristics()
 
3:41 AM
@fge comment
Though as long as it's not radical you can edit it right away, authors can rollback edits
 
fge
@Unihedron this would be a rather heavy edit; as a comment it would be unreadable
(that's what I believe, at least)
 
Sounds like it might be better served as a separate answer if you bother completing it.
 
fge
@Unihedron concrete example: stackoverflow.com/a/26748280/1093528 -- see my second comment in there
I'd rather the poster view a diff of me writing the rundown than view her altered post after the fact
(actually I might end up eating my own dog food and implement these IntStreams -- that will be a good exercise)
 
lol, sounds like a decent challenge, I might try that as well
 
fge
3:56 AM
@Unihedron indecent, I'd say; my word, there doesn't seem to be any helper abstract classes
And no method has a default implementation either
 
Codecraftsmanship :)
 
fge
I must be missing something
I mean, how do you expect implementors to implement all of n methods with n being absurdly large (more than 40 methods)?
 
cross-reference?
 
fge
Not that I haven't encountered that with Path, but Path does not have that many methods to implement
 
I assume some of the methods are wrapper methods you could point to another method for
 
fge
4:00 AM
@Unihedron if that were the case there would be a helper class, or default implementations -- only I see none of these
I am definitely missing something
 
Hmm, maybe the interface is not a functional interface?
 
fge
Uh well, actually it will end up being pretty easy
 
Oh?
 
fge
@Unihedron Stream, a functional interface? :p
 
Oh wait, I'm thinking the wrong thing here :) I forgot what the thing I meant to reference was
 
fge
4:04 AM
@Unihedron just using a builder will do it: docs.oracle.com/javase/8/docs/api/java/util/stream/…
So, basically, all you have to fill in are the digits
 
Huh, really? xD
 
fge
It turns out not to be quite a challenge after all... Except that it challenges your documentation reading abilities :p
Well, then, coffee, plus 5 minutes for coding those streams and pastebinning the code
 
Ohh :)
 
Hello java!
 
hey @Appu
 
fge
4:20 AM
@Unihedron how do you paste code in a chat?
I haven't done it so far
 
@fge You can dump the code, and then click "Fixed Font" which appears to the right of "upload..."
 
fge
Ah
 
fge
I have never used the "upload" button
Anyway: done
 
Well done! :D
 
fge
4:22 AM
Coding digits as they appear is no big deal either
 
Eh... What if I input a negative int?
 
fge
@Unihedron meh, that is POC code :p
In real life, of course you'd test for that (including writing unit tests, of course)
 
fge
@Test(timeout=1000) public void shouldChokeOnNegativeInput() { try { DigitIntStream.digitIntStream(-1); fail("No exception thrown!"); } catch (IllegalArgumentException ignored) { assertTrue(true); } }
(well, I guess you could also test for the error message)
assertThat(e).hasMessage("negative argument is not allowed"); (assuming you use assertj)
 
Bye I'll be back later :P
 
fge
5:05 AM
@Unihedron ping
 
5:17 AM
HI Good morning .... friends......
 
@fge o_o
Morning!
@fge Add a github license :P
 
fge
@Unihedron about JavaBot... I saw that your Guava dependency is on a very old version (10.0.1 iirc) -- why not the latest (18.0)?
 
Hmm I'll check
Oh, that's right! I'll update that. Though Maven is going to download the world again when I'm home.
I'll also give you collaborator privileges so that you can create a branch if you want to work on it. :P
 
fge
No need ;) I can just git clone and submit pull requests :p
 
Yeah, git is great like that :)
 
fge
5:24 AM
Uh, wow
 
Oh?
 
fge
So, this method: docs.oracle.com/javase/8/docs/api/java/util/… uses regexes internally, and can throw a PatternSyntaxException
 
Yep, if you set the pattern in Scanner, the pattern isn't compiled until it has to be used
 
fge
(of course, this is not documented -- would be easy otherwise)
@Unihedron in the quoted question, there is no pattern submitted
It is really .nextInt() which triggers the bug
 
Ah...
 
fge
5:27 AM
That is, uh... Well, a bug
 
Oh, the radix changes how the pattern compiles... With a zero radix, the pattern doesn't compile cause the character class fails to be completed.
 
fge
@Unihedron OK, fine, but why a PatternSyntaxException? I'd have expected an IllegalArgumentException. Granted, the former inherits the latter, but still
Why attempt to build the regex in the first place?
 
That's exactly what the Java devs failed to realize. we should file a bug report ticket to oracle, or something.
 
fge
Note that the documentation for the method does not list IllegalArgumentException as a possible exception -- in fact, it does not list what happens at all if the specified radix is illegal
@Unihedron guess so... Not sure how long it will take for them to fix the bug
I know that a bug I reported took more than 1 month to fix
 
Better than sticking around forever :)
I doubt their devs messes with Scanners all day, so a ticket might be helpful for them
 
fge
5:32 AM
Namely, on Unix systems, Paths.get("").normalize() would throw an AIOOB
It's fixed in the latest 1.7 and 1.8, but I don't know which version fixed that exactly
 
Cool!
 
fge
Not fixed in 1.8b5, I know at least that
But I directly upgraded from b5 to b25, heh
 
:o
 
fge
Anyway, have you had time to explore #freenode's javabot implementation of ~javadoc?
 
I did last night
 
fge
5:37 AM
Meh
 
It's bounded to their main framework really well, which is amazing
 
fge
I still need to send my resume to Amazon
 
Oh?
Good luck!
 
fge
Yup... A dev from there contacted me with regards to my JSON Schema validator
 
:o
 
fge
5:38 AM
Basically, he said "hey, do you have a resume handy?"
 
Sounds promising :P
 
fge
Not so sure about that, but you don't know until you try
 
Well, everything can happen.
Bye for now!
 
fge
I have no professional experience in software development, only amateur experience
 
 
2 hours later…
fge
8:01 AM
Wee, I just figured that my IntStream code has a potential bug
 
8:40 AM
It I have code that takes a txt file and reads it and create arrays of ints from that txt file, is it faster to optimise the code to instead get the int arrays passed instead of reading them from a txt file?
 
fge
1
Q: How to trigger calls to .serializeWithType() of a class implementing JsonSerializable in Jackson?

fgeThis is Jackson 2.2.x. I have a class implementing JsonSerializable; there are two methods to implement for this interface, serialize() and serializeWithType(). I want to test {de,}serialization of this class, and I can trigger calls to serialize() easily; not, however, serializeWithType(). Th...

500 rep for you! Self promotion!
 
8:55 AM
@fge !!!
I want points! I'll see if I can solve it :)
 
fge
@Unihedron yes please! I'm desperate... I've had this problem for more than one year now and I still have not found a way to even trigger this method
 
in Shadow's Den on Meta Stack Exchange Chat, 21 mins ago, by Shadow Wizard
@DroidDev beautiful (everyone in Israel are sure that all girls in Sweden are beautiful)
@Gemtastic ^
 
fge
Hmwell, indeed, I have yet to see an ugly Swedish woman
(but then I have never been to Sweden)
 
9:13 AM
@fge New answer!
 
 
2 hours later…
10:43 AM
JDepend looks cool, thoughts?
 
10:59 AM
@Unihedron How are you doing?
 
@Appu Hello hello!
I'm surfing Stack Overflow at the moment, just submitted a batch of tag wiki edits, and about to code on the chat bot / development of my network
 
@Unihedron big myth is big
Morning btw
 
11:19 AM
Morning!
I wanted your opinion on the message, so. :P
 
Well, fact: tons of ugly girls in sweden
We have a similar myth here though; that all asian girls are beautiful. A lot of people (far from everyone though) think that
 
LOL
 
In my experience, it's not exactly all that flattering that people are convinced all swedish girls are beautiful. I won't tell you why unless you really wanna know. I just thank the gods you aren't one of those kind of guy.
 
inb4 backseat commentary on humanity
 
Hmm?
 
11:28 AM
ignore that lol
 
why asian girls?? anime?
 
shrug.
 
No, this is akinda old myth, 100 years or more. Asian girls are "exotic" and when the brits went there there were tons of brothels for them
And the swedes got it off of the brits
Anime girls don't look like asian girls :P
 
shrug.
 
@Gemtastic T.T I know...
 
11:39 AM
Well, then why do you ask? ;P
Ask me something fun instead. I'm tired of conversations dying because I'm awkward :'(
 
soo... how's the coding coming along?
~is even more awkward
 
well well, it still does that weird error, I'm going to brute force some debugging tonight
If all else fails, I'll just redo the message component
It's possible to apply binary search on a list, but how do I use it on a TreeSet?
It's automatically sorted for sure, but doesn't seem right to copy it over to an array and use Arrays.
I suddenly want to play a game of Monopoly.
 
@Unihedron @Unihedron umm... why not do a tree.tailSet(root); and work on the sorted set you got returned?
 
@Vogel612 Coding's great, just had my first class in FX yesterday
 
@Vogel612 ... It's a set. Is there a standard library method for binary search on sets? I only find the one on lists and arrays.
However it is true that it's an overkill for any advanced algorithm I implement in my code, since it's not a big Set.
 
11:53 AM
Hey
 
Hiya :)
 
Does anyone here have much experience with StyledDocuments?
 
Which library is that from?
 
Swing
 
oh lol..
~lesson -> afk
 
11:55 AM
Ohhh... Haven't experience with that, sorry :(
@Vogel612 See you!
 
Sorry, to be clear, it's in Swing text components
 
This is giving a NullPointerException
`<script>
            var valueManip = new function() {
                if(i+1 === <%=tv1.getNum().size()%> ) {
                    alrt(<%=tv1.getNum().size()%>);
                        <jsp:forward page="result.jsp"></jsp:forward>
    }
    else {
                    <% i++; %>

                }
            </script>`
 
@M.S. Java... SCRIPT>>>
 
This is code of JSP
 
Oh..
Eh... It should be alert
 
11:58 AM
Changed it..
Still same error.
 
Is tv1 defined?
 
Yes it is instance of bean class
 
Did getNum() return null?
 
More error details: pastebin.com/id2ZC5v5
 
oh...
 
12:06 PM
@M.S. line 60 is?
@JazibBashir oh...?
 
12:45 PM
@Unihedron haha
 
 
1 hour later…
1:47 PM
Hi guyz
I want to load a huge xml file (2000+) and then find elements containing some text
each time I only use 3-5 elements from it
so could you advice me what API should i use ?
I already started with jdom, should I continue with it ?
in other words, I need to search the xml file for some nodes (containing some text), then only these nodes will by used in my program
 
If it ain't broke, don't fix it.
Actually, I don't really deal with XML that much. @fge any ideas?
 
2:15 PM
List size is 10 when after entering 10 elements how to delete 1st element and enter new element at 10th place like Queue..please guide me how to do it
 
Write code.
 
2:27 PM
@Unihedron how to move all the elements when removing the first element
 
@Harish What?
 
Good morning, Java!
 
Morning Mic
 
Morning, @Michael!
 
@Unihedron i have inserted 10 elements into the list(Size of the list is 10)now i got new value i want to remove first inserted that ican do list.remove(1).and now how to move all the other elements locations (i.e., 2 to 1 ,3rd to 2nd vice-verse)
 
2:32 PM
Hey @Uni
 
Eh, no you can't do list.remove(1), that's the second element!!!
 
@Enissay Just use Java's XML API.
 
@Harish I'm gonna tell you a basic thing. In java 0 is the first number in a list, because in math, 0 is a positive number, so you count from 0 in the list of arrays or list. When you get the number of items in a list, you will count like normal. If you put 10 elements in a list, .size() will be 10, but the last element will be located in the 9th slot, and the first element will be in slot 0.
 
Reader reader = ...
StreamSource source = new StreamSource(reader);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
DefaultHandler handler = new MyDefaultHandlerImpl();
SAXResult result = new SAXResult(handler);
transformer.transform(source, result);
 
@Gemtastic Yes i agree with You it true.could you please tell me how to do it
moving the elements
 
2:38 PM
@Michael, I was wondering since I only need 5-6 elements out of 2000+, is it necessary to load the full xml for that ? or it is necessary to perform the search ?
 
@Enissay The code sample I posted streams the XML. That means it does not hold the entire DOM in memory at once.
Basically, it parses each XML element one at a time and let's you decide what you want to do with it.
 
@Michael, okay, I see
 
@Harish If you want to re-arrange the items in a list you'll need to re-assign them to the specific spot in the list. Everything you can do with an ArrayList you can find in the JavaDoc: docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html
Or google for tutorials (oracle has its own tutorials too)
 
2:57 PM
@Gemtastic You could had told them to use the System.arraycopy method after creating a new array.
 
@Unihedron You could do that, or you could just sort the arraylist when you want a certain output
I'm still a n00b so I wonder why you would even want to change place on the elements in an arraylist to begin with
 
Hmm..
 
@Gemtastic Umm, sorting? xD
 
@Michael What for? you can apply a soring on the ArrayList, or you could just add the elements in the right order to begin with. Or make a new list that's sorted as uni mentioned.
 
@Gemtastic I don't think they want their array sorted.
 
3:08 PM
So still, moving only a specific few elements in a list seem strange to me.
 
36 mins ago, by Harish
@Unihedron i have inserted 10 elements into the list(Size of the list is 10)now i got new value i want to remove first inserted that ican do list.remove(1).and now how to move all the other elements locations (i.e., 2 to 1 ,3rd to 2nd vice-verse)
 
@Gemtastic Making a new list in order to sort an existing list is inefficient because you must allocate more memory!
 
@Unihedron Yes, that's why I don't know why he'd want to do that
@Michael there are still more options than to go into an array to only switch places of a few very specific items
 
55 mins ago, by Harish
List size is 10 when after entering 10 elements how to delete 1st element and enter new element at 10th place like Queue..please guide me how to do it
^ They want to rebuild a Queue.
 
@Unihedron then he shouldn't use an ArrayList
 
3:11 PM
@Gemtastic well that's the problem and was why I didn't answer :)
in RegEx - Regular Expressions, Oct 29 at 3:09, by Unihedron
fools rush to where angels fear to tread
On a note of mandatory situations to use that quote, here you have one:
5
A: Range 1 to 9223372036854775807 with regular expression

UnihedronDon't use a regex. It's inefficient, and way worse than any integer parsing logic anyone can ever write. For the sake of demonstration, here you go: ^(?:[1-9][0-9]{0,17}|[1-8][0-9]{18}|9(?:[01][0-9]{17}|2(?:[01][0-9]{16}|2(?:[0-2][0-9]{15}|3(?:[0-2][0-9]{14}|3(?:[0-6][0-9]{13}|7(?:[01][0-9]{12}...

 
@Unihedron If you don't answer at all he'll just keep asking
 
shrug
 
I think I've finally finished adding proper timezone support to biweekly! :D
 
:D
 
:D
I earned some points!
 
3:24 PM
Yay for points
 
yay!!
 
My entire amount of points XD
 
Aww :)
The points I earned on my other account was from editing posts though,
There's always dat post in dire of an editor giving a CTRL + K on their code... o_O
 
3:46 PM
You get points from editing too?
 
If you're < 2K rep, you get points for editing any post.
If you're < 20K rep, you get points for editing tag wikis.
That is, for approved edit suggestions only.
 
I need a reference to a method, in a class (java 8 yes), but cannot use the functional interface - I need to be able to accept any kind of method... any pattern that looks better than the hypothetical 'getMethod/getMethodHandle(Foo.class, "methodName")'
ofc I could override the getMethod to accept 1,2,3 ... n argument functional interface, but I need to be able to introspect the method arguments, too...
 
You need a functional interface with a varargs to accept functional interfaces so that you can use ALL the functional interfaces?
functional-interface-ception
 
varargs does not work either :D
say your interface is Object... x, then it is matched by exactly 1 arg of Object... x or Object[] x
 
Holy...
Oh... That's going to be a problem.
 
3:56 PM
I solved a similar problem by having 9 functional interfaces for 0 to 8 arguments (it is fancy yes), but ... then I just have Object apply(Object, Object, Object) with no idea on what it is actually accepting :D
and this is nothing serious, just want to push the boundary of reflection/metaprogramming etc in java :D
 
:)
I was just wondering what good it will be... Oh well, I'm not good enough to work around that :P
 
if a lambda is serialized, the serialized form will give out fancy info
 
Hmm...
interface GiveMeBoolean extends Serializeable {
  boolean yes();
}
GiveMeBoolean yes = () -> true;
 
I mean, if you serialize it, then it is converted to SerializedLambda :D
 
Oh yeah@
 
4:03 PM
which should basically give out stuff
 
fge
No, what you serialize is the call site, not the lambda itself
 
ah yes, the call site... hmmmh
 
fge
And by the way, Serializable incurs a severe linkage cost
 
but it will need to give out the methodhandle too
 
fge
Well, if you use it, you get what you deserve anyway
I have never, and will never, use(d) Serializable
 
4:07 PM
@fge I want to get the methodhandle from my lambda if possible, no matter what the cost :D
 
fge
@AnttiHaapala suit yourself :p I'm not very fluent with reflection at that level
 
me neither :D
 
Ohh! I just had a brilliant idea of an interactive game we can put on the chat bot as a module! :)
 
4:38 PM
@Unihedron Oh?
 
@Michael Oh?
You'll have to wait to see. Bye for now! I'm going to sleep, it's late.
 
@Unihedron Ok :(
 
5:00 PM
aWW
Uni is such a tease!
 
By the way, let's not forget to congratulate a relative of Java!
in Android talkies, 4 mins ago, by Liza
Happy Birthday Android
 
Today's android's birthday?
 
Yeppers!
5 years! :)
 
wow
It's been like two months for it since using Android lol
*for me
Happy Birthday Android!
 
:)
 
5:08 PM
wait, I think 7 years not five?
It was five years anniversary 2 years ago
 
 
1 hour later…
6:26 PM
blah, the serializedlambda can be used to deduce the argument types but it does not disclose the contents of the method reference.
 
 
5 hours later…
11:04 PM
This chat always die when Uni isn't here :(
 
It's cause he has spare time :)
 
Pfft no he hasn't got spare time! He just barely get any sleep :P
(and that's what he's doing right now)
 

« first day (1474 days earlier)      last day (3460 days later) »