Skip to content

Instantly share code, notes, and snippets.

@henrjk
Created August 22, 2016 11:37
Show Gist options
  • Save henrjk/de5d862a07e02d3c4881fea688634edf to your computer and use it in GitHub Desktop.
Save henrjk/de5d862a07e02d3c4881fea688634edf to your computer and use it in GitHub Desktop.
Eclipse errors using Java 7 and Java 6 settings for samples of Core Java for the Impatient (Covers Java8) 2015

Chapter 1: Fundamental Data Structures

Some errors with Java 7 setting

Description	Resource	Path	Location
The method isFinite(double) is undefined for the type Double	NumberDemo.java	ch01/sec02	line 33	
The method toUnsignedInt(byte) is undefined for the type Byte	NumberDemo.java	ch01/sec02	line 15	
The method floorMod(int, int) is undefined for the type Math	ArithmeticDemo.java	ch01/sec04	line 13	
The import java.time cannot be resolved	StringDemo.java	ch01/sec05	line 3	
The method codePoints() is undefined for the type String	StringDemo.java	ch01/sec05	line 63	
The method join(String, String, String, String) is undefined for the type String	StringDemo.java	ch01/sec05	line 18	
ZoneId cannot be resolved	StringDemo.java	ch01/sec05	line 24	

Additional errors with Java 6 settings:

Since 1.7 only:

  • Diamond operator
  • Underscores in constants

Chapter 2: Object Oriented Programming

8 errors with Java 7 setting

Caused by java.time not available

Additional errors with Java 6 settings: Since 1.7 only:

  • Diamond operator

Chapter 3: Interfaces and Lamda Expressions since Java 8

Lots of errors with Java 7 setting

Since 1.8 only

  • Default methods

  • Method references

  • Lambda expressions

  • Constructor references Without proper error reported by Eclipse

  • References to closure variables.

  • The import javafx cannot be resolved

    • The method removeIf(( e) -> {}) is undefined for the type ArrayList LambdaDemo.java ch03/sec04 line 13
    • The method forEach(System.out::println) is undefined for the type ArrayList MethodReferenceDemo.java ch03/sec05 line 14
    • The method removeIf(Objects::isNull) is undefined for the type ArrayList MethodReferenceDemo.java ch03/sec05 line 13
    • The method stream() is undefined for the type ArrayList ConstructorReferenceDemo.java ch03/sec05 line 11
    • Cannot refer to the non-final local variable count defined in an enclosing scope RepeatDemo.java ch03/sec06 line 19
    • FunctionalInterface cannot be resolved to a type PixelFunction.java ch03/sec06 line 5
    • IntConsumer cannot be resolved to a type RepeatDemo.java ch03/sec06 line 12
    • The import java.util.function cannot be resolved RepeatDemo.java ch03/sec06 line 3 ... lots more

Additional errors with Java 6 settings: Since 1.7 only:

  • Diamond operator

Chapter 4: Inheritance and Reflection

6 errors with Java 7 setting

Since 1.8 only

  • Default methods
  • Method references
  • Closure/Lambda in ProxyDemo

Others:

Description	Resource	Path	Location
The method getParameters() is undefined for the type Method	MethodPrinter.java	ch04/sec05	line 20	

Chapter 5: Exceptions, Assertions, and Logging

2 errors with Java 7 setting

Since 1.8 only

  • Lambda expressions.

Additional errors with Java 6 settings:

Since 1.7 only:

  • try-with-resources: Resource specification not allowed here

Chapter 6: Generic Programming

12 errors with Java 7 setting

Causes:

  • Lambda Expressions and related infrastructure.

Details:

Description	Resource	Path	Location
Predicate cannot be resolved to a type	Arrays.java	ch06/sec04	line 6	
The import java.util.function cannot be resolved	Arrays.java	ch06/sec04	line 3	
The method checkedList(List<E>, Class<E>) in the type Collections is not applicable for the arguments (ArrayList<Object>, Class<String>)	HeapPollutionDemo.java	ch06/sec04	line 30	
The method demo(List<String>) in the type HeapPollutionDemo is not applicable for the arguments (ArrayList<Object>)	HeapPollutionDemo.java	ch06/sec04	line 25	
Cannot refer to the non-final local variable path defined in an enclosing scope	Exceptions.java	ch06/sec06	line 24	
IntFunction cannot be resolved to a type	Arrays.java	ch06/sec06	line 7	
Lambda expressions are allowed only at source level 1.8 or above	Exceptions.java	ch06/sec06	line 24	
The import java.util.function cannot be resolved	Arrays.java	ch06/sec06	line 4	
The method getTypeName() is undefined for the type Type	GenericReflectionDemo.java	ch06/sec07	line 32	

4 additional errors with Java 6 settings:

Since 1.7 only:

  • Diamond operator

Chapter 7: Collections

14 errors with Java 7 setting

Since 1.8 only

  • Lambda expressions.
  • Method references

Others:

Description	Resource	Path	Location
The method compute(String, (<no type> k, <no type> v) -> {}) is undefined for the type Map<String,Integer>	Test.java	ch07/scratch	line 12	
The method removeIf((<no type> e) -> {}) is undefined for the type Collection<String>	IteratorDemo.java	ch07/sec02	line 26	
The method forEach((<no type> k, <no type> v) -> {}) is undefined for the type Map<String,Integer>	MapDemo.java	ch07/sec04	line 28	
The method getOrDefault(String, int) is undefined for the type Map<String,Integer>	MapDemo.java	ch07/sec04	line 14	
The method merge(String, int, Integer::sum) is undefined for the type Map<String,Integer>	MapDemo.java	ch07/sec04	line 19	
The method forEach((<no type> k, <no type> v) -> {}) is undefined for the type Properties	PropertiesDemo.java	ch07/sec05	line 34	

17 additional errors with Java 6 settings:

Since 1.7 only:

  • diamond operator
  • try-with-resources: Resource specification not allowed here

Chapter 8: Streams since Java 8

Lots of errors with Java 7 setting

Chapter 9: Processing Input and Output

46 errors with Java 7 setting

Since 1.8 only

  • Stream
  • Lambda expressions.
  • Method references

Others:

  • java fx not available

    Description Resource Path Location The method lines() is undefined for the type BufferedReader TextIO.java ch09/sec01 line 42 The method lines(Path, Charset) is undefined for the type Files TextIO.java ch09/sec01 line 25 The import java.io.UncheckedIOException cannot be resolved DirectoryDemo.java ch09/sec02 line 4 The method lines(Path) is undefined for the type Files ZipDemo.java ch09/sec02 line 29 The method list(Path) is undefined for the type Files DirectoryDemo.java ch09/sec02 line 17 The method walk(Path) is undefined for the type Files DirectoryDemo.java ch09/sec02 line 22 The method walk(Path) is undefined for the type Files DirectoryDemo.java ch09/sec02 line 30 The method walk(Path) is undefined for the type Files ZipDemo.java ch09/sec02 line 31 Collectors cannot be resolved FindingOneOrAllMatches.java ch09/sec04 line 24 Collectors cannot be resolved RemovingOrReplacingMatches.java ch09/sec04 line 17 The method asPredicate() is undefined for the type Pattern FindingOneOrAllMatches.java ch09/sec04 line 23 The method splitAsStream(CharSequence) is undefined for the type Pattern RemovingOrReplacingMatches.java ch09/sec04 line 16 The method putIfAbsent(int, Person) is undefined for the type Map<Integer,Person> PersonDatabase.java ch09/sec05 line 18

19 additional errors with Java 6 settings:

Since 1.7 only:

  • diamond operator
  • try-with-resources: Resource specification not allowed here

Chapter 10: Concurrent Programming

Lots of errors with Java 7 setting Perhaps a bit surprising as there should be a lot of old stuff in there as well. Only sec09 has no errors!

Since 1.8 only

  • Stream
  • Lambda expressions and closures
  • Method references
  • LongAccumulator and LongAdder since java.util.concurrent.atomic.

Others:

*javafx related in sec 8

Description	Resource	Path	Location
Collectors cannot be resolved	CallableDemo.java	ch10/sec01	line 37	
The method newKeySet() is undefined for the type ConcurrentHashMap	QueueDemo.java	ch10/sec06	line 11	
The method withInitial(() -> {}) is undefined for the type ThreadLocal	ThreadLocalDemo.java	ch10/sec07	line 16	

Chapter 11: Annotations

Lots of errors with Java 7 setting sec04 and sec05 has no errors! (same with Java 6)

Since 1.8 only

  • type annotations
  • Explicit declaration of 'this' parameter
  • Method references
  • Repeatable annotations

Others:

Description	Resource	Path	Location
Duplicate annotation @BugReport. Repeated annotations are allowed only at source level 1.8 or above	AnnotationDemo.java	ch11/sec01	line 46	
Explicit declaration of 'this' parameter is allowed only at source level 1.8 or above	Point.java	ch11/sec01	line 12	
Function cannot be resolved to a typeUseAnnotations.java	ch11/sec01	line 29	
Syntax error, type annotations are available only when source level is at least 1.8	AnnotationDemo.java	ch11/sec01	line 56	
The annotation @Immutable is disallowed for this location	AnnotationDemo.java	ch11/sec01	line 56	
The annotation @NonNull is disallowed for this locationUseAnnotations.java	ch11/sec01	line 16	
The import java.util.function cannot be resolvedUseAnnotations.java	ch11/sec01	line 8	
The method reverseOrder() is undefined for the type ComparatorUseAnnotations.java	ch11/sec01	line 15	
The target type of this expression must be a functional interfaceUseAnnotations.java	ch11/sec01	line 29	

_PARAMETER cannot be resolved or is not a field AnnotationDemo.java ch11/sec01 line 15 _USE cannot be resolved or is not a field ReadOnly.java ch11/sec01 line 6 _USE cannot be resolved or is not a fieldUseAnnotations.java ch11/sec01 line 10 _USE cannot be resolved or is not a fieldUseAnnotations.java ch11/sec01 line 11 FunctionalInterface cannot be resolved to a type StandardAnnotations.java ch11/sec03 line 41

Chapter 12: Date and Time since Java 8

All errors with Java 7 setting

Chapter 13: Internationalization

Some errors with Java 7 setting section 2,3,7-9 have no errors!

Since 1.8 only

  • java.time

  • Lambdas

  • String#codePoints() method

    Description Resource Path Location DateTimeFormatter cannot be resolved Locales.java ch13/sec01 line 18 FormatStyle cannot be resolved to a variable Locales.java ch13/sec01 line 18 LocalDate cannot be resolved Locales.java ch13/sec01 line 19 The import java.time cannot be resolved Locales.java ch13/sec01 line 4 LocalTime cannot be resolved to a type DateAndTimeFormatting.java ch13/sec04 line 23 The method codePoints() is undefined for the type String CollatorDemo.java ch13/sec05 line 55 The method sort(Collator) is undefined for the type ArrayList CollatorDemo.java ch13/sec05 line 16 Instant cannot be resolved MessageFormatDemo.java ch13/sec06 line 9

Additional errors with Java 6 settings:

Since 1.7 only:

  • Diamond operator
  • try-with-resources: Resource specification not allowed here

Chapter 14: Compiling and Scripting

2 errors with Java 7 setting

Description	Resource	Path	Location
Cannot refer to the non-final local variable classes defined in an enclosing scope	CompilerDemo.java	ch14/sec01	line 43	
The method newBufferedReader(Path, Charset) in the type Files is not applicable for the arguments (Path)	CompileDemo.java	ch14/sec02	line 20	

2 additional errors with Java 6 settings:

Since 1.7 only:

  • Diamond operator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment