Generics were added to the Java language more than 10 year ago. But do you really understand them?
Well discuss:
What is heap pollution?
How does the compiler translate generics?
Why its not allowed to create parametrized array (List<string>[])
What are bridge methods, can we reach them?
Type erasure rules
Difference between List, List<object>, List<?>
Why its not allowed to add Integer to List<?>
Why its not allowed to parameterize exception classes?
Whats wrong with Collections.max signature: <t><?>> T max(Collection<?> coll);
Code that should be compiled, but cant be compiled and vice versa
How to write good API using generics and wildcards
And other generic puzzlers
Olexandra Dmytrenko
QA Automating at EPAM Systems
I'll show you how to switch from writing standard code using good old Java7 into writing it using functional way presented in Java8. The training is counted on beginners in the subject who like discovering the new horizons or for those who want to become more firm in using the new lambda features.
Developers want to make very few errors in their code and to spot them as early as possible: with the help of unit tests, or earlier, during compilation, or best of all, immediately after they typed something wrong in their IDE. This is what static code analyzers are for. Some of them are built-in, others need to be run separately, some check just about any code, the others require it to be annotated first, and there are tools that are a little bit of all. Do the ends justify the means? Is it even worth trying? What kind of errors can be spotted by static code analysis? How sure can we be if what an analyzer gives us is a real error or a false positive? This talk hopefully helps you answer these questions.
Each month, join us as we highlight and discuss hot topics ranging from the future of higher education to wearable technology, best productivity hacks and secrets to hiring top talent. Upload your 際際滷Shares, and share your expertise with the world!
Not sure what to share on 際際滷Share?
際際滷Shares that inform, inspire and educate attract the most views. Beyond that, ideas for what you can upload are limitless. Weve selected a few popular examples to get your creative juices flowing.
How to Make Awesome 際際滷Shares: Tips & Tricks際際滷Share
油
Turbocharge your online presence with 際際滷Share. We provide the best tips and tricks for succeeding on 際際滷Share. Get ideas for what to upload, tips for designing your deck and more.
際際滷Share is a global platform for sharing presentations, infographics, videos and documents. It has over 18 million pieces of professional content uploaded by experts like Eric Schmidt and Guy Kawasaki. The document provides tips for setting up an account on 際際滷Share, uploading content, optimizing it for searchability, and sharing it on social media to build an audience and reputation as a subject matter expert.
Olexandra Dmytrenko
QA Automating at EPAM Systems
I'll show you how to switch from writing standard code using good old Java7 into writing it using functional way presented in Java8. The training is counted on beginners in the subject who like discovering the new horizons or for those who want to become more firm in using the new lambda features.
Developers want to make very few errors in their code and to spot them as early as possible: with the help of unit tests, or earlier, during compilation, or best of all, immediately after they typed something wrong in their IDE. This is what static code analyzers are for. Some of them are built-in, others need to be run separately, some check just about any code, the others require it to be annotated first, and there are tools that are a little bit of all. Do the ends justify the means? Is it even worth trying? What kind of errors can be spotted by static code analysis? How sure can we be if what an analyzer gives us is a real error or a false positive? This talk hopefully helps you answer these questions.
Each month, join us as we highlight and discuss hot topics ranging from the future of higher education to wearable technology, best productivity hacks and secrets to hiring top talent. Upload your 際際滷Shares, and share your expertise with the world!
Not sure what to share on 際際滷Share?
際際滷Shares that inform, inspire and educate attract the most views. Beyond that, ideas for what you can upload are limitless. Weve selected a few popular examples to get your creative juices flowing.
How to Make Awesome 際際滷Shares: Tips & Tricks際際滷Share
油
Turbocharge your online presence with 際際滷Share. We provide the best tips and tricks for succeeding on 際際滷Share. Get ideas for what to upload, tips for designing your deck and more.
際際滷Share is a global platform for sharing presentations, infographics, videos and documents. It has over 18 million pieces of professional content uploaded by experts like Eric Schmidt and Guy Kawasaki. The document provides tips for setting up an account on 際際滷Share, uploading content, optimizing it for searchability, and sharing it on social media to build an audience and reputation as a subject matter expert.
47. 仍亳 亰亟亠 亠从舒 仗舒仄亳?
public class Foo {
void foo() {
Runnable r = new Runnable() {
public void run() {
System.out.println("Bye!");
}
};
Runtime.getRuntime()
.addShutdownHook(new Thread(r));
}
...
}
47
48. 舒, 亠 仍从舒 仆舒 于仆亠仆亳亶 仂弍亠从
class Foo$1 implements Runnable {
final Foo this$0;
public Foo$1(Foo foo) {
this$0 = foo;
}
...
}
48
49. 亅从亰亠仄仗仍 仂亰亟舒 从舒亢亟亶 舒亰
ContainerUtil.filter(methods,
new Condition<PsiMethod>() {
public boolean value(PsiMethod psiMethod) {
return psiMethod.isConstructor();
}
}
);
49
50. 仂 仂 从仂仄仗亳仍亳仂于舒 仍磡仄亟?
public class Simple {
public static void main(String[] args) {
Runnable r =
() -> System.out.println("Hello");
new Thread(r).start();
}
}
50
51. 弌舒仄舒 仗仂舒 亠舒仍亳亰舒亳 舒仆仂仆亳仄
public class Simple {
public static void main(String[] args) {
Runnable r = new Runnable() {
public void run() {
System.out.println("Hello");
}
}
new Thread(r).start();
}
}
51
57. 仍 仆舒舒仍舒 亟亠仍舒亠仄 desugaring
public class Simple {
public static void main(String[] args) {
Runnable r = Simple::lambda$main$0;
new Thread(r).start();
}
private static void lambda$main$0() {
System.out.println("Hello");
}
}
57
58. MethodHandle
public abstract class MethodHandle {
@PolymorphicSignature
public final native Object invoke(Object... args)
throws Throwable;
public MethodType type() { ... }
...
}
public class MethodType {
public static MethodType methodType(Class<?> rtype) {...}
public static MethodType methodType(Class<?> rtype,
Class<?> ptype0) {...}
...
}
58
60. 亠舒仍亳亰舒亳 仍礆弍亟, 仗仂仗从舒 1
public class LambdaMetafactory {
public static Object metafactory0(
String samMethodName,
Class<?> samType,
MethodType samMethodType,
MethodHandle implMethod) {
...
Class cls = Unsafe.getUnsafe()
.defineAnonymousClass(...);
return cls.newInstance();
}
} 60
61. 亠舒仍亳亰舒亳 仍礆弍亟, 仗仂仗从舒 1
public class Simple {
public static void main(String[] args) throws Throwable {
MethodHandle implMethod =
MethodHandles.lookup().findStatic(Simple.class,
"lambda$main$0", MethodType.methodType(void.class));
MethodType samMethodType = MethodType.methodType(void.class);
Runnable r = (Runnable) LambdaMetafactory.metafactory0(
"run", Runnable.class, samMethodType, implMethod);
new Thread(r).start();
}
private static void lambda$main$0() {
System.out.println("Hello");
}
}
61
62. 仂仗从舒 2: 从亳亠仄 仍礆弍亟
public class Simple {
private static Object[] lambdas = new Object[1];
public static void main(String[] args) throws Throwable {
if (lambdas[0] == null) {
...
lambdas[0] = LambdaMetafactory.metafactory0(
"run", Runnable.class, samMethodType, implMethod);
}
Runnable r = (Runnable) lambdas[0];
new Thread(r).start();
}
...
}
62
63. CallSite
public abstract class CallSite {
public abstract MethodHandle getTarget();
...
}
public class ConstantCallSite extends CallSite {
public ConstantCallSite(MethodHandle target) {...}
}
63