« first day (1526 days earlier)      last day (3402 days later) » 
00:00 - 16:0016:00 - 00:00

fge
12:17 AM
0
Q: Can you make mockito (1.10.17) work with default methods in interfaces?

fgeI am a big fan of mockito, unfortunately for one of my projects which uses Java 8, it fails on me... Scenario: public final class MockTest { @Test public void testDefaultMethodsWithMocks() { final Foo foo = mock(Foo.class); //when(foo.bar()).thenCallRealMethod(); ...

 
I meant, more processor ticks in the JVM or access to a different Threadpool
fge, do you have up to date jdoc in that library?
Also mockito doesn't run if it's into a bullitn console
 
fge
12:39 AM
@MarcosEusebi eh?
 
For example, mockito causes an error on eclipse.
nope, sorry.
eclipse causes an error on mockito
 
fge
I don't care about Eclipse
I use IDEA
 
then nvm
 
fge
1:01 AM
Ahwell, it looks like I'm SOL
 
Adz
1:22 AM
hello
 
fge
2:07 AM
`final ThrowingUnaryOperator<Path> o = Path::toRealPath;

FIles.list(somedir).map(o.orReturnSelf()).forEach(System.out::println);`
Hehe, throwing-lambdas allows some pretty good stuff
 
3:01 AM
Scanner f = new Scanner(System.in);
int num1 = f.nextInt();
int num2 = f.nextInt();
System.out.println(num1 + num2);
i don't know why this code fails to run..
 
fge
3:16 AM
@AvinashRaj and how does it fail?
wagers for a NumberFormatException
 
But this works perfectly.
	    Scanner one = new Scanner(System.in);
	   System.out.println("Number 1 :" );
	    int num1 = one.nextInt();
	   Scanner two = new Scanner(System.in);
	    System.out.println("NUmber 2 :" );
	    int num2 = two.nextInt();
	   System.out.println("Age accepted " + num2);
	    System.out.println(num1 + num2);
i think it's because of lack of System.out.println stmt before each number.
@fge no, it displays any exception.
Thanks Bye..
 
fge
And what exception is that, huh?
 
 
1 hour later…
fge
4:28 AM
throwing-lambdas version 0.2.0 released!
 
5:20 AM
Yay
 
 
2 hours later…
7:02 AM
Morning!
 
7:26 AM
Mrng
 
8:22 AM
@ItachiUchiha Yes, the community version; Though, I see they have a Student License, I think I'll go with that. If IntelliJ helps me in my journey, I'll buy a commercial license when I can afford it (actually I can already afford one, but you know what I mean)
 
9:02 AM
@Unihedro :)
 
@ItachiUchiha .. Guess what?
It crashed when I started it up:
 
what?
 
haha
and I thought Eclipse is the only IDE which crashes :P
 
Great, it won't even load now.
 
9:04 AM
try an older version
 
I'm using the latest version of Ultimate, but it seems not to be happy. I'll restart my computer if that helps.
 
hmm, try restarting
but if it doesn't fix
then there might be some bug in this release
 
Updated java_home and it fixed it.
 
@Unihedro They should catch the exception and show a user friendly message :P
 
ikr
Cool, IntelliJ automagically converted an eclipse project into their project! This is amazing!
 
9:27 AM
@Unihedro Even netbeans does that :P
 
9:53 AM
Building my Eclipse theme on IntelliJ :)
 
10:40 AM
OMG
The maven dependency turns red, and when the import is done, it turns green! Wow!
 
screenshot
I want to see it
 
It's green, so all is good.
 
show me red
 
How? :P
 
add a dependency
and save the file
initially it will take time to download
and will be red for sometime :P
 
10:42 AM
 
woah
that is cool
 
 
1 hour later…
fge
12:04 PM
Moo
 
hey all
@fge Had some time to try implementing the MapStream. github.com/alexcrt/JavaBoost/blob/master/README.md
 
fge
@ZouZou saw that and just commented on it
 
@fge But I don't know how to do that
 
fge
Eh?
 
the problem is the of factory method
 
fge
12:07 PM
@ZouZou didn't you forget that in 1.8 you can have static methods in interfaces? :p
 
@fge I know
but how would you return a new MapStream from the map?
 
fge
static <K,V> MapStream<K, V> of(Map<K, V> victim) { return victim.entrySet().stream(); }
And that's about it
 
nah doesn't compile
cannot convert from Stream<Map.Entry<K,V>> to MapStream<K,V>
 
fge
Ah, uh, wait
 
I already tried
but I didn't manage too
that's why I created a class and had to delegate the majority of the methods...
unfortunately
 
fge
12:11 PM
Hmmm
Heey, wait
Just cast
gist.github.com/fge/7e7054170e8a0c0280f0 <-- this compiles at least
You may want to give it a try
 
not you cannot
do this
Exception in thread "main" java.lang.ClassCastException: java.util.stream.ReferencePipeline$Head cannot be cast to MapStream
already tried
:D
 
fge
OK :p
Well yeah, then a class it seems that it is
Darn
 
actually I don't think that's posible
yep
 
fge
Hey, any reason why there are surefire reports in your commits?
 
wut ?
what is that?
 
fge
12:15 PM
That's what I see in pull request #16 for instance
 
/target files
 
fge
Didn't you see the list of files?
Did you fill your .gitignore?
 
You should gitignore them, or at least interactively commit and filter out those files, they're garbage
 
fge
@Unihedro btw, 0.2.0 released
 
@fge I saw, really great work! Looks fantastic! :)
 
12:17 PM
ah yes I should gitignore them
i didn't notice
 
fge
@Unihedro I have a s*load of ideas, heh
 
Isn't that the thing we all love about leading projects? To get new ideas and implementing them, then gazing over what you have across the week
 
fge
@ZouZou in order to get rid of them you have to do two things: add target to .gitignore then git rm -r --cached target; then commit that result
 
echo "/target" > .gitignore
 
fge
(and push it fast
@Unihedro >>, not >
@Unihedro do you have ideas? :p
 
12:19 PM
@fge sorry, I blame my keyboard
@fge Yeah, sell it to IBM and get rich
 
fge
@ZouZou there is still a way of doing an interface out of it, I believe
But nevermind that
@Unihedro won't do that, sorry :p
 
:P
 
@fge The thing that I don't understand is that you are able to do
@Override
    public MapStream<K, V> sequential() {
        return new MapStream<K, V>(delegate.sequential());
    }
 
Actually, I don't really have any ideas.
 
(note that @Override)
ah no wait
that's a different thing
nvm
 
fge
12:27 PM
@ZouZou simply define the interface and create one implementation (DefaultMapStream) which is package private
This way you can add default methods and not bother implement them in the default implementation
And you can use your factory method in the interface (return new DefaultMapStream<K, V>(arguments, here))
@Unihedro I have at least two
 
:O
 
fge
One is easy: an .or() on all interfaces which would take as an argument a non throwing version
Also, an alternative name to .wrap() for this; that would be for instance tryWith()
As in Functions.tryWith(Path::toRealPath).or(Path::toAbsolutePath)
 
Oh!
Speaking of ideas, I just had one - Why not change the return type of rethrow to ThrowableFoo?
 
fge
@Unihedro I'm hesitating on just deprecating rethrow, but... Nah, after all, maybe not
But you're right, in fact it could just delegate to .wrap()
 
Nom!
 
fge
12:33 PM
Also, .orTryWith() on all interfaces as well
Which would take another Throwing and return a Throwing
tryWith(1).orTryWith(2).or(default)
Similary, in line with rethrow(), .as() could be an alias to .orThrow()
rethrow(Path::toRealPath).as(FooException.class)
 
@fge So you say interface MapStream
 
fge
But first I need to improve tests
 
and class DefaultMapStream implements MapStream?
 
fge
@ZouZou yes
 
@fge Sweet!
 
fge
12:36 PM
@Unihedro comments?
 
Both sounds amazing.
 
fge
OK, so there are at least two things which need to be done at first
Alias rethrow() to wrap() and improve tests
Two branches!
Oh, and add tryWith()
Well, this and rethrow() can be the same branch
doesn't know where to start
Ah yeah, there's also something that bothers me with .orThrow() and ThrowablesFactory
 
Oh?
 
fge
now really doesn't know where to start
Haven't tried yet but I think it's be better if the type variable E disappeared and I used Class<? extends RuntimeException> everywhere
Well, first, test improvements
(needed)
 
Let me kill eclipse and I'll see where you left off
 
fge
12:41 PM
By the way, do git fetch --all --prune next time
I've purged the topic/* branches
 
Just did so I won't forget :)
 
tanks
thanks
Map<Integer, String> map = MapStream.of(create(1, "John"),
                                        create(2, "Alice"),
                                        create(3, "Bob")).collect();
sweeeet
 
fge
@ZouZou default methods rock :p
 
+1
 
fge
@Unihedro have you seen the readme/wiki updates too?
 
12:54 PM
@fge Yes, I skimmed through them, I liked how you put it a lot :)
@fge What is "IDEtalk"?
 
fge
@Unihedro no... idea (pun not intended), never used it
CS theory masturbation question of the day: calculate the big O of bogosort for quantum computers
:p
 
Eh... mmm... erm...
dies
 
fge
1:10 PM
I wouldn't even begin to tackle this question, I don't have enough CS baggage for that
And I know of no CS boffin either
(meh, I feel like asking the question on cstheory, just for fun)
 
:P
I'm trying to figure out how to know if a file's been saved. Back when I used Eclipse, the file name would have an asterisk to denote unsaved changes.
 
fge
In IDEA?
 
ya
 
fge
Well, it saves automatically for you by default
I don't know how it does it, however
 
Wait, really? No wonder why Ctrl + S doesn't do anything...
 
1:32 PM
@fge Yeah you had a good idea with this mapStream
we can do funny things like
Map<String, List<Integer>> map1 = MapStream.of(create("ok", Arrays.asList(1, 2))).collect();
Map<String, List<Integer>> map2 = MapStream.of(create("ok", Arrays.asList(3, 4))).collect();
MapStream.of(map1, map2)
           .mergeKeys()
           .mapValues(l -> l.stream().flatMap(List::stream).collect(Collectors.toList()))
           .collect()
           .forEach((k, v) -> System.out.println(k+" => "+v));
which outputs:
(I let you guess)
:DDD
 
fge
Yeah, I can guess :p
Makes me think
Hmmno, forget about it
@ZouZou anyway, the day when you really want to implement a native ByteStream (using AbstractPipeline and such) there's a trick
I used it for implementing the glob PathMatcher in java7-fs-base
 
1:48 PM
Good morning, Java!
 
hey
 
Hi @ZouZou!
 
fge
Good morning milord
Milord, you may be interested in this (shameless self advertising)
 
Shameless promotion detected!
grabs popcorn
 
@Unihedro Dang it Uni, stop breaking things! xD
 
fge
1:51 PM
:p
 
@fge Functions can't throw exceptions?
 
fge
@Michael unchecked only
Not checked
And it's the same story with all functional interfaces
 
@fge That's handy.
Ah, ok.
 
@Michael The unimplemented methods in java.util.function interfaces doesn't allow throwing exceptions, which deems many great candidate functions in lambda form unable to be used. throwing-lambdas is there to remedy this.
 
fge
All those used in streams anyway
 
1:54 PM
Some people think having checked exceptions in Java was a mistake.
 
fge
Yeah, but I disagree with them :p
The problem is that by design a lambda cannot propagate an exception out of its context to begin with
If they were able to this project would probably never have been created
 
Ah.
 
fge
But that's super handy
For instance you can parallel collect Futures with this!
 
@fge lol
 
fge
final List<Foo> results = executor.invokeAll(callables).parallelStream().map(Functions.wrap(Future::get).o‌​rReturn(null)).collect(Collectors.toList());
Done!
 
1:58 PM
You can use a static import to make it more concise.
 
fge
Yes you can
 
final List<Foo> results = executor.invokeAll(callables).parallelStream().map(wrap(Future::get).o‌​rReturn(null)).collect(toList());
 
fge
Or you can affect the wrap result to a variable: final Function<Future<Foo>, Foo> f = Functions.wrap(Future::get).orReturn(null);
 
Ah, so you can use it multiple times.
 
fge
Yup
Or you can final ThrowingFunction<Future<Foo>, Foo> f = Functions.wrap(Future::get);
 
2:01 PM
Yay! Set up Gradle and IDEA is happy.
 
I guess if you use orThrow(), you have to pass in a RuntimeException.
 
fge
This way you can decide in the stream how to behave
@Michael yes
 
@fge Does it check for that?
 
fge
Yes it does
default <E extends RuntimeException> orThrow(Class<E> exceptionClass) { ... }
 
And I presume the exception class must have a constructor that accepts an Exception object.
 
fge
2:03 PM
A Throwable, but yes
All Errors and RuntimeExceptions are thrown "untouched"
All checked exceptions are wrapped with either ThrownByLambdaException or your own exception class
 
@fge Hey I wanted to push the javadoc on a github page, I followed the tuto for creating the repo username.github.io, added the hello world
unfortunately when trying to access alexcrt.github.io
i get a 404
 
fge
And chaining methods depend on what they are; for instance, you can BinaryOperators.wrap(something).orReturnLeft()
 
did I do something wrong?
 
fge
@ZouZou which tutorial? I usually do that by publishing to gh-pages
 
2:05 PM
@ZouZou The URL syntax is: username.github.io/project-name
 
fge
And then the doc would be available at username.github.io/projectname
 
@ZouZou make a gh-pages branch as it tells you
 
@fge That's nice.
 
under "user / organization pages or project pages"
 
fge
@Michael and it's not over yet; next step: more meaningful names
@Michael for instance: rethrow(foo).as(MyException.class); tryAnd(foo).orTry(bar).or(default); etc etc
The fact that all of these use methods on interfaces means that I don't even need a "finisher" method, I can simply rethrow(foo) if I want
 
2:08 PM
@Unihedro But it's a different thing from the User site right?
 
fge
@ZouZou yes indeed
 
@ZouZou yes, you're setting up a static site or a project site? You really should go for the second.
I'll get you a link to the tutorials...
 
Why?
I could create the user site which points to multipe project sites (if any)
shouldn't it be the way you build that?
 
@ZouZou No, because 1. It's not linked to the project, and 2. It's static.
You would see that others' projects has a subdirectory under your .github.io subdomain, but that's because they are project pages, not because they have actual subdirectories.
Building your own directories which conflicts with project names of projects you have are... Well, if it's not outright bad, it's not good.
 
I see
their themes are pretty cool!
 
2:26 PM
song-rec-plz
 
fge
Huh, coming with a good structure for tests but it's going to be loooooong
 
List it, I'll do my best
(try to)
 
fge
@Unihedro I'm into trial-and-error-designing it at the moment; if you'd like I'd appreciate the changing return type for rethrow()
And, uh, after that I hesitate between tryWith().orTryWith() and tryAnd().orTry()
(I guess that'll be the first one)
 
@fge So ditch wrap and change all return types of rethrow?
 
fge
No, let wrap be
Just change the return type of rethrow and make it just return wrap(whatever);
 
2:32 PM
Ok! So practically, it's doing nothing?
And add @deprecated?
 
fge
Yup, just "aliasing"
No, not even that
I believe the name makes sense in some situations, such as rethrow().as()
 
I can ignore Comparators yes? Or change it as well?
 
fge
Why would you ignore comparators?
 
It only has one method
 
fge
Well, hey, consistency is good, ya know :p
 
2:34 PM
@fge Why not rename it to try()? Oh wait, that won't work...
@fge OK, but Comparators doesn't have wrap(), should I leave it as is except changing the return type?
 
fge
It doesn't?
Uh, that's a mistake from me
It should have
 
Uh... One second, I may need to pull :P
 
fge
Make that a branch by the way
 
fge/master -> local/master checkout local/changetype
brb grab snacks while this pulls
Yeah, wrap exists!
What does this mean? Code contains easter egg?
 
fge
2:51 PM
@Unihedro meh, no idea
Where is that?
In inspections?
 
Yeah.
Well I just wrote a regex to replace one every fourth \bc\b into wrap(c).
 
fge
What does the description say?
 
> An "easter egg" is code deliberately hidden in the code, both from potential users and even from other developers. This lint check looks for code which looks like it may be hidden from sight.
 
Code-seption.
 
This IntelliJ wrapping code into a single line feature is driving me nuts
hits enter oh wait, hits backspace; type type aha! hits enter ehh no hits backspace twice
How to change the position of the pointer line? The vertical one, it's pointing at 120, I want 80
 
fge
2:57 PM
@Unihedro Ctrl-Shift-[+-] to expand/collapse
 
Yay!
Thanks!
 
fge
@Unihedro also, you have a very good VIM plugin if you prefer vim-like editing (which I do)
 
Yeah! It works!
I still want to change the position of the vertical guide:
 
@fge Sorry for the dumb question but I begin with git. I just want to put the javadoc in the gh-pages branch, but I need to be in the master one to build it. How do you do? You build the doc from master, and put in in a locat directory, then switch to gh-branch and push the javadoc generated?
(without the code, only the docs)
 
@ZouZou You can stash, then go to gh-pages branch, and pop your stash at working copy, then commit to the branch?
 
3:06 PM
ah stash ftw
 
Found it! Editor > Code Style > Right margin
 
fge
@ZouZou in this case what I do is clone again my local repo to projectname-javadoc, add the remote, create the gh-pages branch, generate javadoc, copy it over, add and push; there are many ways to do it
I prefer another copy because switching between the "code branchs" and gh-pages can be a PITA
 
ok I'll try
is there any way to write the doc in this way
instead of
@see java.util.function.ByteUnaryOperator
I want
No.
Instead of @see java.util.function.BinaryOperator, I want @see BinaryOperator which redirects to the java.util.function one
is it possible?
 
Oh no! IntelliJ doesn't support \K in regexes.
;-;
 
fge
@Unihedro it uses the Java regex engine
And hey, IDEA has a s*load of refactoring options
It is infinitely better than Eclipse at that
 
3:17 PM
(?s)\brethrow\(\s*+final Throwing\w++(?:<[^>]++>)?\s(.)[^}]*?return \1
There you go.
s~(?s)(\brethrow\(\s*+final Throwing\w++(?:<[^>]++>)?\s(.)[^}]*?return )\2~$1wrap($2)
 
fge
@Bohemian hmmm, I guess I can answer that one ;)
 
L8r
 
LOL
 
fge
0
A: How can I throw CHECKED exceptions from inside Java 8 streams?

fgeYou cannot. However, you may want to have a look at one of my projects which allows you to more easily manipulate such "throwing lambdas". In your case, you would be able to do that: import static com.github.fge.lambdas.functions.Functions.wrap; final ThrowingFunction<String, Class<?>> f = wr...

There :p
 
3:28 PM
You lucky duck :P The package is going to help the programmer very nicely, well done!
 
fge
Meh, this project is a gold mine actually
Which is why I want it thoroughly tested!
 
It has the return types changed, should I PR or wait until you have idea?
(thinks all the intellij puns are no longer funny by now)
This is not rocket science. Anytime you have a mix of complex structures that you want to move the match position past, especially when lookbehinds are variable in length, you have to match the bad conditions. Otherwise, the match position will never advance, there is no other way. Basically, its a simple (?:s1|s2|s3)|(\b\d{5}\b) just a check for group 1 on each match. My question is why @Unihedro opened a new bounty on this? — sln 20 hours ago
 
fge
@Unihedro just PR
 
Whoa - an entire paragraph against me opening a bounty.
 
fge
I actually have another idea (yeah, I know, bad pun)
It is the test refactoring which gave me up this... idea (aaargh)
 
3:34 PM
You made me roll my paper over and coughed like a madman. Were anyone watching, they would throw me out of the window.
 
fge
Wait, I'll code it and pastebin it
You'll understand
 
hi
is this the good example to learn service based framework?
 
Didn't even click on it, but it's made back in 2011.
 
lolwhat
 
fge
3:41 PM
@Unihedro this means we could make ThrowingFunction<T, R> extends Function<T, R>, ThrowingFunctionalInterface<ThrowingFunction<T, R>, Function<T, R>>
 
Every interface will extend both Foo and ThrowingFI?
 
fge
That's a wild idea for now
I need to play with it a little
 
Wow!
That's A++!
You can even downcast it to ThrowingFI and all three extenders can be used to return a proper Foo
 
fge
In fact that would even be ThrowingFunctionalInterface<T extends N, N>
Well, I need to play with it, as I said
(and I also need to merge your work)
 
fge
3:58 PM
@Unihedro merged
 
\o/
 
Greetings.
 
Greetings!
 
fge
Hello @Mr.777
 
Hiya
 
3:59 PM
While you're working out how the stuff is going to be laid out I'm going to work on JCE again. Ping me if I can be any of help.
 
00:00 - 16:0016:00 - 00:00

« first day (1526 days earlier)      last day (3402 days later) »