Skip to main content
8 votes
1 answer
253 views

Here's a minimal demo: public class OuterStaticNestedDemo<E> { class Outer { static class StaticNested {} } void qualifiedNew(Outer outer) { new Outer.StaticNested();...
Nicolas Baumann's user avatar
5 votes
0 answers
85 views

The contract for Types#directSupertypes(TypeMirror) says that it will return "the direct supertypes of a type". It also references section 4.10 of the Java Language Specification. The set of ...
Laird Nelson's user avatar
  • 16.6k
4 votes
1 answer
225 views

Introduction Consider this Java program: public class Loop { static volatile boolean flag; public static void main(String[] args) { new Thread(() -> flag = true).start(); ...
Haspamelodica's user avatar
1 vote
2 answers
139 views

There seems to be a similar question (Java Specification: reads see writes that occur later in the execution order), but it focuses on a different example. The Java Memory Model states in §17.4.8: ...
yaskovdev's user avatar
  • 1,354
3 votes
1 answer
147 views

Do I understand correctly that if I run run1() and run2() in parallel, the result r1 == 0 and r2 == 0 is impossible under any circumstances, even though a and b are not volatile? public class Example {...
yaskovdev's user avatar
  • 1,354
0 votes
0 answers
70 views

I'm trying to understand the Memory Model chapter from the Java Language Specification, but I'm already confused by the first two paragraphs: A memory model describes, given a program and an ...
yaskovdev's user avatar
  • 1,354
2 votes
0 answers
58 views

Consider the rules of allowed narrowing reference conversion mentioned in the JLS section 1.5.6.1. The following is an example of a narrowing reference conversion: ArrayList<? extends Integer> l ...
Mohamed Nasser's user avatar
2 votes
1 answer
56 views

Consider the following clause from JLS 8: § 15.9.5.1. Anonymous Constructors Note that it is possible for the signature of the anonymous constructor to refer to an inaccessible type (for example, if ...
theutonium.18's user avatar
1 vote
0 answers
188 views

I have some confusion about how method references work. The following is an example from JLS 15.13.1: An example of ambiguity is: interface Fun<T,R> { R apply(T arg); } class C { int ...
user24723440's user avatar
3 votes
0 answers
75 views

I was working on a project that parses Java code. While testing my project on some code I found out that it throws an error on cases like the one under, specifically on the conversion of type B<A&...
Jog Ming's user avatar
0 votes
1 answer
90 views

JLS 4.5.2: If any of the type arguments in the parameterization of C are wildcards, then: • The types of the fields, methods, and constructors in C<T1,...,Tn> are the types of the fields, ...
user24723440's user avatar
-1 votes
1 answer
81 views

interface A{ } interface B{ } interface C{ } interface D extends A,B,C{ } If there is: class N<T extends A & B & C> According to the content of JLS 4.9: Every intersection type T1 ...
user24723440's user avatar
1 vote
2 answers
184 views

I don't understand this passage in the Java Language Specification : JLS § 4.9: The values of an intersection type are those objects that are values of all of the types Ti for 1 ≤ i ≤ n. As far as I ...
user24723440's user avatar
2 votes
2 answers
252 views

Consider this rule from the Java Language Specification 21th edition: It is a compile-time error if a class C inherits a default method whose signature is override-equivalent with another method ...
Mohamed Nasser's user avatar
0 votes
1 answer
89 views

JLS 4.8: It is a compile-time error to pass type arguments to a non-static member class or interface of a raw type that is not inherited from its superclasses or superinterfaces. I can't think of ...
user24723440's user avatar

15 30 50 per page
1
2 3 4 5
27