Examples of javac diagnostics

Index

Examples: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

compiler.err.abstract.cant.be.accessed.directly AbstractCantBeAccessed.java
compiler.err.abstract.cant.be.instantiated AbstractCantBeInstantiated.java
compiler.err.abstract.meth.cant.have.body AbstractMethodCantHaveBody.java
compiler.err.already.defined AlreadyDefined.java, UnnamedPackage.java
compiler.err.already.defined.in.clinit AlreadyDefinedClinit.java, KindnameInstanceInit.java, KindnameStaticInit.java
compiler.err.already.defined.single.import AlreadyDefinedImport.java
compiler.err.already.defined.static.single.import AlreadyDefinedStaticImport
compiler.err.annotation.missing.default.value AnnotationMissingValue.java
compiler.err.annotation.missing.default.value.1 AnnotationMissingValues1.java
compiler.err.annotation.not.valid.for.type AnnoNotValidForType.java
compiler.err.annotation.type.not.applicable AnnoNotApplicable.java
compiler.err.annotation.value.must.be.annotation AnnoValueMustBeAnnotation.java
compiler.err.annotation.value.must.be.class.literal AnnoValueMustBeClassLiteral.java
compiler.err.annotation.value.must.be.name.value AnnotationMustBeNameValue.java
compiler.err.annotations.not.supported.in.source AnnotationsNotSupported.java
compiler.err.anon.class.impl.intf.no.args AnonClassImplInterfaceNoArgs.java
compiler.err.anon.class.impl.intf.no.qual.for.new AnonClassImplInterfaceNoQualForNew.java
compiler.err.anon.class.impl.intf.no.typeargs AnonClassImplInterfaceNoTypeArgs.java
compiler.err.array.and.receiver ArrayAndReceiver.java
compiler.err.array.and.varargs ArrayAndVarargs.java
compiler.err.array.dimension.missing ArrayDimMissing.java
compiler.err.array.req.but.found ArrayRequired.java
compiler.err.assert.as.identifier AssertAsIdentifier2.java
compiler.err.attribute.value.must.be.constant AttrMustBeConstant.java
compiler.err.bad.functional.intf.anno.1 BadFunctionalIntfAnno.java
compiler.err.bad.initializer ForeachBadInitialization.java
compiler.err.break.outside.switch.loop BreakOutsideSwitchLoop.java
compiler.err.call.must.be.first.stmt.in.ctor CallMustBeFirst.java
compiler.err.call.to.super.not.allowed.in.enum.ctor SuperNotAllowedInEnum.java
compiler.err.cannot.create.array.with.diamond CannotCreateArrayWithDiamond.java
compiler.err.cannot.create.array.with.type.arguments CannotCreateArrayWithTypeArgs.java
compiler.err.cant.access BadSourceFileHeader
compiler.err.cant.annotate.nested.type CantAnnotateNestedType.java
compiler.err.cant.annotate.static.class CantAnnotateStaticClass.java
compiler.err.cant.apply.diamond CantApplyDiamond.java
compiler.err.cant.apply.diamond.1 DiamondAndAnonClass.java, DiamondAndExplicitParams.java, DiamondNonGeneric.java
compiler.err.cant.apply.symbol BadArgTypesInLambda.java, ExplicitParamsDoNotConformToBounds.java, InaccessibleVarargsType, IncompatibleArgTypesInMethodRef.java, IncompatibleEqUpperBounds.java, InferArgsLengthMismatch.java, InferNoConformingAssignment.java, InferVarargsArgumentMismatch.java, InferredDoNotConformToEq.java, InferredDoNotConformToUpper.java, KindnameConstructor.java, NoArgs.java, NotApplicableMethodFound.java, VarargsArgumentMismatch.java, VerboseResolveMulti1.java, WhereCaptured.java, WhereCaptured1.java, WhereTypeVar.java
compiler.err.cant.apply.symbols InapplicableSymbols.java, IncompatibleUpperBounds.java
compiler.err.cant.assign.val.to.final.var CantAssignToFinal.java
compiler.err.cant.deref CantDeref.java
compiler.err.cant.extend.intf.annotation CantExtendIntfAnno.java
compiler.err.cant.inherit.diff.arg CantInheritDiffArg.java
compiler.err.cant.inherit.from.final EnumTypesNotExtensible.java, InheritFromFinal.java
compiler.err.cant.ref.before.ctor.called CantRefBeforeConstr.java
compiler.err.cant.ref.non.effectively.final.var CantRefNonEffectivelyFinalVar.java
compiler.err.cant.resolve CantResolve.java
compiler.err.cant.resolve.args CantResolveArgs.java
compiler.err.cant.resolve.args.params CantResolveArgsParams.java
compiler.err.cant.resolve.location CantResolveLocation.java, KindnameClass.java, KindnameVariable.java, Location.java, Location1.java, StaticImportOnlyClassesAndInterfaces
compiler.err.cant.resolve.location.args CantResolveLocationArgs.java, KindnameMethod.java
compiler.err.cant.resolve.location.args.params CantResolveLocationArgsParams.java
compiler.err.catch.without.try CatchWithoutTry.java
compiler.err.clash.with.pkg.of.same.name PkgClashWithClass
compiler.err.class.cant.write ClassCantWrite.java
compiler.err.class.not.allowed NotAllowedClass.java
compiler.err.class.public.should.be.in.file ClassPublicInFile.java
compiler.err.concrete.inheritance.conflict ConcreteInheritanceConflict.java
compiler.err.const.expr.req ConstExprRequired.java
compiler.err.cont.outside.loop ContinueOutsideLoop.java
compiler.err.cyclic.annotation.element CyclicAnnoElement.java
compiler.err.cyclic.inheritance CyclicInheritance.java
compiler.err.dc.bad.entity BadEntity.java
compiler.err.dc.bad.gt BadGreaterThan.java
compiler.err.dc.bad.inline.tag BadInlineTag.java
compiler.err.dc.gt.expected GreaterThanExpected.java
compiler.err.dc.identifier.expected RefIdentifierExpected.java
compiler.err.dc.malformed.html MalformedHTML.java
compiler.err.dc.missing.semicolon MissingSemicolon.java
compiler.err.dc.no.content NoContent.java
compiler.err.dc.no.tag.name NoTagName.java
compiler.err.dc.ref.bad.parens RefBadParens.java
compiler.err.dc.ref.syntax.error RefSyntaxError.java
compiler.err.dc.ref.unexpected.input RefUnexpectedInput.java
compiler.err.dc.unexpected.content UnexpectedContent.java
compiler.err.dc.unterminated.inline.tag UnterminatedInlineTag.java
compiler.err.dc.unterminated.signature UnterminatedSignature.java
compiler.err.default.allowed.in.intf.annotation.member DefaultAllowedInIntfAnnotationMember.java
compiler.err.default.methods.not.supported.in.source DefaultMethodNotSupported.java
compiler.err.default.overrides.object.member DefaultOverridesObjectMember.java
compiler.err.diamond.not.supported.in.source DiamondNotSupported.java
compiler.err.does.not.override.abstract DoesNotOverride.java
compiler.err.doesnt.exist DoesntExist.java
compiler.err.dot.class.expected DotClassExpected.java
compiler.err.duplicate.annotation DuplicateAnnotation.java
compiler.err.duplicate.annotation.invalid.repeated InvalidDuplicateAnnotation.java
compiler.err.duplicate.annotation.member.value DuplicateAnnotationMemberValue.java
compiler.err.duplicate.annotation.missing.container DuplicateAnnotationJava8.java
compiler.err.duplicate.case.label DuplicateCaseLabel.java
compiler.err.duplicate.class DuplicateClass.java
compiler.err.duplicate.default.label DuplicateDefaultLabel.java
compiler.err.else.without.if ElseWithoutIf.java
compiler.err.empty.char.lit EmptyCharLiteral.java
compiler.err.encl.class.required EnclClassRequired.java
compiler.err.enum.annotation.must.be.enum.constant EnumAnnoValueMustBeEnumConst.java
compiler.err.enum.as.identifier EnumAsIdentifier2.java
compiler.err.enum.cant.be.instantiated EnumCantBeInstantiated.java
compiler.err.enum.label.must.be.unqualified.enum EnumLabelUnqualified.java
compiler.err.enum.no.finalize EnumNoFinalize.java
compiler.err.enum.no.subclassing EnumNoSubclassing.java
compiler.err.enum.types.not.extensible EnumTypesNotExtensible.java
compiler.err.enums.must.be.static EnumsMustBeStatic.java
compiler.err.enums.not.supported.in.source EnumsNotSupported.java
compiler.err.error CompressedDiags.java, CountError.java, CountErrorPlural.java, Error.java, IdentifierExpected.java, KindnameClass.java, KindnameConstructor.java, KindnameInstanceInit.java, KindnameMethod.java, KindnameStaticInit.java, KindnameVariable.java, ProbFoundReqFragment.java
compiler.err.error.reading.file ErrorReadingFile.java
compiler.err.except.already.caught ExceptAlreadyCaught.java
compiler.err.except.never.thrown.in.try ExceptNeverThrown.java
compiler.err.expected ArrayAndReceiver.java, IdentifierExpected.java, IllegalDot.java, InvalidBinaryNumber.java, InvalidHexNumber.java
compiler.err.expected2 Expected2.java
compiler.err.expected3 ArrayAndReceiver.java, Expected3.java, IllegalStartOfStmt.java
compiler.err.final.parameter.may.not.be.assigned FinalParamCantBeAssigned.java
compiler.err.finally.without.try FinallyWithoutTry.java
compiler.err.foreach.not.applicable.to.type ForeachNotApplicable.java
compiler.err.foreach.not.supported.in.source ForeachNotSupported.java
compiler.err.fp.number.too.large FloatNumberTooLarge.java
compiler.err.fp.number.too.small FloatNumberTooSmall.java
compiler.err.generic.array.creation GenericArrayCreation.java
compiler.err.generic.throwable GenericThrowable.java
compiler.err.generics.not.supported.in.source GenericsNotSupported.java
compiler.err.icls.cant.have.static.decl InnerClassCantHaveStatic.java
compiler.err.illegal.char IllegalChar.java
compiler.err.illegal.combination.of.modifiers IllegalComboModifiers.java
compiler.err.illegal.default.super.call OverriddenDefault.java, RedundantSupertype.java
compiler.err.illegal.dot IllegalDot.java
compiler.err.illegal.enum.static.ref IllegalEnumStaticRef.java
compiler.err.illegal.esc.char IllegalEscapeChar.java
compiler.err.illegal.forward.ref IllegalForwardRef.java
compiler.err.illegal.generic.type.for.instof InvalidInstanceof.java
compiler.err.illegal.initializer.for.type IllegalInitializer.java
compiler.err.illegal.line.end.in.char.lit IllegalLineEndInCharLit.java
compiler.err.illegal.nonascii.digit IllegalNonAsciiDigit.java
compiler.err.illegal.qual.not.icls IllegalQualNotIcls.java
compiler.err.illegal.self.ref IllegalSelfRef.java
compiler.err.illegal.start.of.expr IllegalStartOfExpr.java, MalformedFpLit.java
compiler.err.illegal.start.of.stmt IllegalStartOfStmt.java
compiler.err.illegal.start.of.type ArrayAndReceiver.java, IllegalDot.java, InvalidBinaryNumber.java
compiler.err.illegal.static.intf.meth.call IllegalStaticIntfMethCall.java
compiler.err.illegal.underscore IllegalUnderscore.java
compiler.err.illegal.unicode.esc IllegalUnicodeEscape.java
compiler.err.import.requires.canonical ImportRequiresCanonical
compiler.err.improperly.formed.type.inner.raw.param ImproperTypeInnerRawParam.java
compiler.err.improperly.formed.type.param.missing ImproperTypeParamMissing.java
compiler.err.incomparable.types IncomparableTypes.java
compiler.err.incompatible.thrown.types.in.lambda IncompatibleThrownTypesInLambda.java
compiler.err.incompatible.thrown.types.in.mref IncompatibleThrownTypesInMref.java
compiler.err.incorrect.constructor.receiver.name IncorrectConstructorReceiverName.java
compiler.err.incorrect.constructor.receiver.type IncorrectConstructorReceiverType.java
compiler.err.incorrect.receiver.name IncorrectReceiverName.java
compiler.err.incorrect.receiver.type IncorrectReceiverType.java
compiler.err.initializer.must.be.able.to.complete.normally InitializerMustComplete.java
compiler.err.int.number.too.large IntNumberTooLarge.java
compiler.err.intersection.types.in.cast.not.supported.in.source IntersectionTypesInCastNotSupported.java
compiler.err.intf.annotation.cant.have.type.params IntfAnnotationCantHaveTypeParams.java
compiler.err.intf.annotation.member.clash IntfAnnotationMemberClash.java
compiler.err.intf.annotation.members.cant.have.params IntfAnnotationsCantHaveParams.java
compiler.err.intf.annotation.members.cant.have.type.params IntfAnnotationsCantHaveTypeParams.java
compiler.err.intf.expected.here InterfaceExpected.java
compiler.err.intf.meth.cant.have.body IntfMethodCantHaveBody.java
compiler.err.intf.not.allowed.here InterfaceNotAllowed.java
compiler.err.invalid.annotation.member.type InvalidAnnoMemberType.java
compiler.err.invalid.binary.number IdentifierExpected.java, InvalidBinaryNumber.java
compiler.err.invalid.hex.number InvalidHexNumber.java
compiler.err.invalid.meth.decl.ret.type.req InvalidMethodDecl.java
compiler.err.invalid.mref CantResolveLocationArgsFragment.java, CantResolveLocationArgsParamsFragment.java, NonStaticCantBeRefFragment.java, StaticBoundMref.java, StaticMethodInUnboundLookup.java, StaticMrefWithTargs.java
compiler.err.invalid.repeatable.annotation.elem.nondefault InvalidDuplicateAnnotation.java, RepeatableNonDefault.java
compiler.err.invalid.repeatable.annotation.incompatible.target RepeatableTargetMismatch.java
compiler.err.invalid.repeatable.annotation.no.value RepeatableNoValue.java
compiler.err.invalid.repeatable.annotation.not.documented RepeatableDocumentedMismatch.java
compiler.err.invalid.repeatable.annotation.not.inherited RepeatableInheritedMismatch.java
compiler.err.invalid.repeatable.annotation.repeated.and.container.present RepeatingAnnotationAndContainer.java
compiler.err.invalid.repeatable.annotation.retention RepeatableRetentionMismatch.java
compiler.err.invalid.repeatable.annotation.value.return RepeatableWrongValueType.java
compiler.err.label.already.in.use LabelInUse.java
compiler.err.lambda.not.supported.in.source LambdaNotSupported.java
compiler.err.local.enum LocalEnum.java
compiler.err.local.var.accessed.from.icls.needs.final LocalVarNeedsFinal.java
compiler.err.malformed.fp.lit MalformedFpLit.java
compiler.err.method.does.not.override.superclass MethodDoesNotOverride.java
compiler.err.method.references.not.supported.in.source MethodReferencesNotSupported.java
compiler.err.missing.meth.body.or.decl.abstract MissingMethodBody.java
compiler.err.missing.ret.stmt MissingReturnStatement.java
compiler.err.mod.not.allowed.here ModifierNotAllowed.java
compiler.err.multicatch.not.supported.in.source MulticatchNotSupported.java
compiler.err.multicatch.parameter.may.not.be.assigned MulticatchCantBeAssigned.java
compiler.err.multicatch.types.must.be.disjoint MulticatchTypesMustBeDisjoint.java
compiler.err.name.clash.same.erasure NameClashSameErasure.java
compiler.err.name.clash.same.erasure.no.hide NameClashSameErasureNoHide.java
compiler.err.name.clash.same.erasure.no.override NameClashSameErasureNoOverride.java
compiler.err.name.clash.same.erasure.no.override.1 NameClashSameErasureNoOverride1.java
compiler.err.native.meth.cant.have.body NativeMethodCantHaveBody.java
compiler.err.neither.conditional.subtype NeitherConditionalSubtype.java
compiler.err.new.not.allowed.in.annotation NewNotAllowedInAnno.java
compiler.err.no.annotations.on.dot.class NoAnnotationsOnDotClass.java
compiler.err.no.intf.expected.here NoInterfaceExpected.java, NoInterfaceHere.java
compiler.err.no.superclass NoSuperclass.java
compiler.err.non-static.cant.be.ref NonStaticCantBeRef.java
compiler.err.not.def.access.class.intf.cant.access NotDefAccessClassIntfCantAccess
compiler.err.not.def.public.cant.access NotDefPublicCantAccess
compiler.err.not.encl.class NotEnclClass.java
compiler.err.not.in.profile NotInProfile.java
compiler.err.not.loop.label NotLoopLabel.java
compiler.err.not.stmt NotAStatement.java
compiler.err.not.within.bounds NotWithinBounds.java
compiler.err.operator.cant.be.applied OperatorCantBeApplied.java
compiler.err.operator.cant.be.applied.1 OperatorCantBeApplied1.java
compiler.err.orphaned Orphaned.java
compiler.err.override.incompatible.ret ClashesWith.java, OverrideIncompatibleReturn.java
compiler.err.override.meth OverrideMeth.java
compiler.err.override.meth.doesnt.throw OverrideDoesntThrow.java
compiler.err.override.static OverrideStatic.java
compiler.err.override.weaker.access CantImplement.java, OverrideWeakerAccess.java
compiler.err.pkg.annotations.sb.in.package-info.java PackageAnnos.java
compiler.err.pkg.clashes.with.class.of.same.name PkgClashWithClass
compiler.err.premature.eof EmptyCharLiteral.java, InvalidBinaryNumber.java, PrematureEOF.java, UnclosedComment.java
compiler.err.prob.found.req BadArgTypesInLambda.java, CantAccessInnerClsConstr.java, CantApplyDiamond1.java, CantApplySymbolFragment.java, CantApplySymbolsFragment.java, CompressedDiags.java, ConditionalTargetCantBeVoid.java, CyclicInference.java, IncompatibleAbstracts.java, IncompatibleArgTypesInLambda.java, IncompatibleDescsInFunctionalIntf.java, IncompatibleRetTypeInLambda.java, IncompatibleRetTypeInMref.java, IncompatibleTypes1.java, IncompatibleTypesInConditional.java, InconvertibleTypes.java, InvalidGenericLambdaTarget.java, MissingReturnValue.java, MissingReturnValueFragment.java, NoAbstracts.java, NoSuitableFunctionalIntfInst.java, NotAFunctionalIntf.java, NotAnInterfaceComponent.java, NotDefAccessClassIntfCantAccessFragment.java, NotDefPublicCantAccessFragment, PossibleLossPrecision.java, ProbFoundReqFragment.java, RefAmbiguousFragment.java, ResourceNotApplicableToType.java, UnexpectedReturnValue.java, WhereFreshTvar.java, WhereIntersection.java
compiler.err.proc.cant.find.class ProcCantFindClass
compiler.err.proc.messager ErrProcMessager, ProcFileReopening, ProcIllegalFileName, ProcTypeRecreate
compiler.err.proc.no.explicit.annotation.processing.requested NoExplicitAnnoProcRequested.java
compiler.err.proc.processor.cant.instantiate ProcessorCantInstantiate
compiler.err.proc.processor.not.found ProcessorNotFound.java
compiler.err.proc.processor.wrong.type ProcessorWrongType
compiler.err.qualified.new.of.static.class IllegalQualNotIcls.java, QualifiedNewStaticClass.java
compiler.err.receiver.parameter.not.applicable.constructor.toplevel.class ReceiverParameterNotApplicableConstructor.java
compiler.err.recursive.ctor.invocation RecursiveConstrInvocation.java
compiler.err.ref.ambiguous RefAmbiguous.java
compiler.err.repeated.annotation.target RepeatedAnnotationTarget.java
compiler.err.repeated.interface RepeatedInterface.java
compiler.err.repeated.modifier RepeatedModifier.java
compiler.err.report.access ReportAccess.java
compiler.err.ret.outside.meth ReturnOutsideMethod.java
compiler.err.static.imp.only.classes.and.interfaces StaticImportOnlyClassesAndInterfaces
compiler.err.static.import.not.supported.in.source StaticImportNotSupported.java
compiler.err.static.intf.methods.not.supported.in.source StaticIntfMethodNotSupported.java
compiler.err.string.const.req StringConstRequired.java
compiler.err.string.switch.not.supported.in.source StringSwitchNotSupported.java
compiler.err.synthetic.name.conflict ErrSyntheticNameConflict.java
compiler.err.this.as.identifier ThisAsIdentifier.java
compiler.err.throws.not.allowed.in.intf.annotation ThrowsNotAllowedInAnno.java
compiler.err.try.resource.may.not.be.assigned ResourceMayNotBeAssigned.java
compiler.err.try.with.resources.not.supported.in.source TryResourceNotSupported.java
compiler.err.try.without.catch.finally.or.resource.decls TryWithoutCatchOrFinallyOrResource.java
compiler.err.try.without.catch.or.finally TryWithoutCatchOrFinally.java
compiler.err.type.annotations.not.supported.in.source TypeAnnotationsNotSupported.java
compiler.err.type.doesnt.take.params TypeNoParams.java
compiler.err.type.found.req TypeFoundRequired.java, TypeReqClassArray.java, TypeReqRef.java
compiler.err.type.var.cant.be.deref TypeVarCantBeDeref.java
compiler.err.type.var.may.not.be.followed.by.other.bounds TypeVarMayNotBeFollowedByOtherBounds.java
compiler.err.types.incompatible.abstract.default TypesIncompatibleAbstractDefault.java
compiler.err.types.incompatible.diff.ret IncompatibleDescsInFunctionalIntf.java, TypesIncompatible.java
compiler.err.types.incompatible.unrelated.defaults TypesIncompatibleUnrelatedDefaults.java
compiler.err.unclosed.char.lit EmptyCharLiteral.java, UnclosedCharLiteral.java
compiler.err.unclosed.comment UnclosedComment.java
compiler.err.unclosed.str.lit UnclosedStringLiteral.java
compiler.err.undef.label UndefinedLabel.java
compiler.err.unexpected.lambda UnexpectedLambda.java
compiler.err.unexpected.mref UnexpectedMref.java
compiler.err.unreachable.stmt UnreachableStatement.java
compiler.err.unreported.exception.default.constructor UnreportedExceptionDefaultConstructor.java
compiler.err.unreported.exception.implicit.close UnreportedExceptionImplicitClose.java
compiler.err.unreported.exception.need.to.catch.or.throw CountError.java, CountErrorPlural.java, UnreportedException.java
compiler.err.unsupported.binary.lit UnsupportedBinaryLiteral.java
compiler.err.unsupported.encoding UnsupportedEncoding.java
compiler.err.unsupported.fp.lit UnsupportedFpLit.java
compiler.err.unsupported.underscore.lit UnsupportedUnderscoreLiteral.java
compiler.err.var.might.already.be.assigned VarMightAlreadyBeAssigned.java
compiler.err.var.might.be.assigned.in.loop MightBeAssignedInLoop.java
compiler.err.var.might.not.have.been.initialized VarMightNotHaveBeenInitialized.java
compiler.err.varargs.and.old.array.syntax VarargsAndOldArraySyntax.java
compiler.err.varargs.and.receiver VarargsAndReceiver.java
compiler.err.varargs.invalid.trustme.anno TrustMeOnNonVarargsMeth.java, TrustMeOnVirtualMethod.java
compiler.err.varargs.not.supported.in.source VarargsNotSupported.java
compiler.err.variable.not.allowed NotAllowedVariable.java
compiler.err.void.not.allowed.here VoidNotAllowed.java
compiler.err.warnings.and.werror Error.java, WarningAndWerror.java
compiler.err.wrong.number.type.args WrongNumberTypeArgs.java
compiler.misc.anonymous.class AnonymousClass.java
compiler.misc.applicable.method.found ApplicableMethodFound.java, VerboseResolveMulti.java
compiler.misc.applicable.method.found.1 ApplicableMethodFound1.java, DeferredMethodInst.java, PartialInstSig.java
compiler.misc.arg.length.mismatch CantApplySymbolsFragment.java, InapplicableSymbols.java, IncompatibleUpperBounds.java, NoArgs.java
compiler.misc.bad.arg.types.in.lambda BadArgTypesInLambda.java
compiler.misc.bad.intersection.target.for.functional.expr NotAnInterfaceComponent.java
compiler.misc.bad.source.file.header BadSourceFileHeader
compiler.misc.cant.access.inner.cls.constr CantAccessInnerClsConstr.java
compiler.misc.cant.apply.diamond.1 CantApplyDiamond1.java
compiler.misc.cant.apply.symbol CantApplySymbolFragment.java
compiler.misc.cant.apply.symbols CantApplySymbolsFragment.java
compiler.misc.cant.implement CantImplement.java
compiler.misc.cant.override OverrideDoesntThrow.java, OverrideIncompatibleReturn.java, OverrideMeth.java, OverrideStatic.java, OverrideUncheckedThrown.java, OverrideWeakerAccess.java
compiler.misc.cant.resolve.location.args CantResolveLocationArgsFragment.java
compiler.misc.cant.resolve.location.args.params CantResolveLocationArgsParamsFragment.java
compiler.misc.captured.type WhereCaptured.java, WhereCaptured1.java
compiler.misc.clashes.with ClashesWith.java
compiler.misc.conditional.target.cant.be.void ConditionalTargetCantBeVoid.java
compiler.misc.count.error CompressedDiags.java, CountError.java, Error.java, KindnameClass.java, KindnameConstructor.java, KindnameInstanceInit.java, KindnameMethod.java, KindnameStaticInit.java, KindnameVariable.java, ProbFoundReqFragment.java
compiler.misc.count.error.plural CountErrorPlural.java, IdentifierExpected.java
compiler.misc.count.warn CountWarn.java, Error.java
compiler.misc.count.warn.plural CountWarnPlural.java
compiler.misc.cyclic.inference CyclicInference.java
compiler.misc.descriptor IncompatibleDescsInFunctionalIntf.java
compiler.misc.descriptor.throws IncompatibleDescsInFunctionalIntf.java
compiler.misc.diamond CantApplyDiamond.java, CantApplyDiamond1.java
compiler.misc.diamond.and.anon.class DiamondAndAnonClass.java
compiler.misc.diamond.and.explicit.params DiamondAndExplicitParams.java
compiler.misc.diamond.non.generic DiamondNonGeneric.java
compiler.misc.explicit.param.do.not.conform.to.bounds ExplicitParamsDoNotConformToBounds.java
compiler.misc.fatal.err.no.java.lang NoJavaLang.java
compiler.misc.file.doesnt.contain.class BadSourceFileHeader
compiler.misc.inaccessible.varargs.type InaccessibleVarargsType
compiler.misc.inapplicable.method CantApplySymbolsFragment.java, InapplicableSymbols.java, IncompatibleUpperBounds.java
compiler.misc.incompatible.abstracts IncompatibleAbstracts.java
compiler.misc.incompatible.arg.types.in.lambda IncompatibleArgTypesInLambda.java
compiler.misc.incompatible.arg.types.in.mref IncompatibleArgTypesInMethodRef.java
compiler.misc.incompatible.descs.in.functional.intf IncompatibleDescsInFunctionalIntf.java
compiler.misc.incompatible.eq.upper.bounds CantApplyDiamond1.java, IncompatibleEqUpperBounds.java
compiler.misc.incompatible.ret.type.in.lambda ConditionalTargetCantBeVoid.java, IncompatibleRetTypeInLambda.java, MissingReturnValueFragment.java
compiler.misc.incompatible.ret.type.in.mref IncompatibleRetTypeInMref.java
compiler.misc.incompatible.type.in.conditional IncompatibleTypesInConditional.java
compiler.misc.incompatible.upper.bounds IncompatibleUpperBounds.java
compiler.misc.inconvertible.types BadArgTypesInLambda.java, CantApplySymbolFragment.java, CantApplySymbolsFragment.java, CompressedDiags.java, IncompatibleRetTypeInLambda.java, IncompatibleRetTypeInMref.java, IncompatibleTypesInConditional.java, InconvertibleTypes.java, InferNoConformingAssignment.java, InferVarargsArgumentMismatch.java, KindnameConstructor.java, NotApplicableMethodFound.java, ProbFoundReqFragment.java, ResourceNotApplicableToType.java, VarargsArgumentMismatch.java, VerboseResolveMulti1.java, WhereFreshTvar.java, WhereTypeVar.java
compiler.misc.infer.arg.length.mismatch InferArgsLengthMismatch.java
compiler.misc.infer.no.conforming.assignment.exists IncompatibleArgTypesInMethodRef.java, InferNoConformingAssignment.java
compiler.misc.infer.no.conforming.instance.exists IncompatibleTypes1.java
compiler.misc.infer.varargs.argument.mismatch InferVarargsArgumentMismatch.java
compiler.misc.inferred.do.not.conform.to.eq.bounds InferredDoNotConformToEq.java, WhereCaptured.java, WhereCaptured1.java
compiler.misc.inferred.do.not.conform.to.upper.bounds InferredDoNotConformToUpper.java, WhereIntersection.java
compiler.misc.inner.cls CantRefNonEffectivelyFinalVar.java
compiler.misc.intersection.type WhereIntersection.java
compiler.misc.invalid.generic.lambda.target InvalidGenericLambdaTarget.java
compiler.misc.invalid.mref CantAccessInnerClsConstr.java, CantApplySymbolFragment.java, CantApplySymbolsFragment.java, NotDefAccessClassIntfCantAccessFragment.java, NotDefPublicCantAccessFragment, ProbFoundReqFragment.java, RefAmbiguousFragment.java
compiler.misc.kindname.class KindnameClass.java, KindnameConstructor.java, KindnameInstanceInit.java, KindnameMethod.java, KindnameStaticInit.java, KindnameVariable.java
compiler.misc.kindname.constructor KindnameConstructor.java
compiler.misc.kindname.instance.init KindnameInstanceInit.java
compiler.misc.kindname.interface Error.java
compiler.misc.kindname.method KindnameMethod.java, ProbFoundReqFragment.java
compiler.misc.kindname.static.init KindnameStaticInit.java
compiler.misc.kindname.variable KindnameInstanceInit.java, KindnameStaticInit.java, KindnameVariable.java
compiler.misc.lambda CantRefNonEffectivelyFinalVar.java
compiler.misc.location CantResolveLocation.java, CantResolveLocationArgs.java, CantResolveLocationArgsFragment.java, CantResolveLocationArgsParams.java, CantResolveLocationArgsParamsFragment.java, KindnameClass.java, KindnameMethod.java, KindnameVariable.java, Location.java, StaticImportOnlyClassesAndInterfaces
compiler.misc.location.1 Location1.java
compiler.misc.missing.ret.val MissingReturnValue.java, MissingReturnValueFragment.java
compiler.misc.no.abstracts NoAbstracts.java
compiler.misc.no.args NoArgs.java
compiler.misc.no.conforming.assignment.exists BadArgTypesInLambda.java, CantApplySymbolFragment.java, CantApplySymbolsFragment.java, KindnameConstructor.java, NotApplicableMethodFound.java, VerboseResolveMulti1.java, WhereTypeVar.java
compiler.misc.no.suitable.functional.intf.inst NoSuitableFunctionalIntfInst.java
compiler.misc.non-static.cant.be.ref NonStaticCantBeRefFragment.java
compiler.misc.not.a.functional.intf BadFunctionalIntfAnno.java, NotAFunctionalIntf.java
compiler.misc.not.a.functional.intf.1 IncompatibleAbstracts.java, NoAbstracts.java
compiler.misc.not.an.intf.component NotAnInterfaceComponent.java
compiler.misc.not.applicable.method.found NotApplicableMethodFound.java, VerboseResolveMulti1.java
compiler.misc.not.def.access.class.intf.cant.access NotDefAccessClassIntfCantAccessFragment.java
compiler.misc.not.def.public.cant.access NotDefPublicCantAccessFragment
compiler.misc.overridden.default OverriddenDefault.java
compiler.misc.partial.inst.sig ApplicableMethodFound1.java, DeferredMethodInst.java, PartialInstSig.java
compiler.misc.possible.loss.of.precision PossibleLossPrecision.java
compiler.misc.prob.found.req ProbFoundReqFragment.java
compiler.misc.redundant.supertype RedundantSupertype.java
compiler.misc.ref.ambiguous RefAmbiguousFragment.java
compiler.misc.static.bound.mref StaticBoundMref.java
compiler.misc.static.method.in.unbound.lookup StaticMethodInUnboundLookup.java
compiler.misc.static.mref.with.targs StaticMrefWithTargs.java
compiler.misc.token.identifier IdentifierExpected.java
compiler.misc.try.not.applicable.to.type ResourceNotApplicableToType.java
compiler.misc.type.null WhereCaptured1.java
compiler.misc.type.parameter TypeFoundRequired.java
compiler.misc.type.req.array.or.iterable ForeachNotApplicable.java
compiler.misc.type.req.class TypeFoundRequired.java
compiler.misc.type.req.class.array TypeReqClassArray.java
compiler.misc.type.req.ref TypeReqRef.java
compiler.misc.type.var WhereTypeVar.java
compiler.misc.unchecked.assign CountWarn.java, CountWarnPlural.java, UncheckedAssign.java, UncheckedFilenameAdditional.java, UncheckedMethodInvocation.java, UncheckedPluralAdditional
compiler.misc.unchecked.cast.to.type UncheckedCast.java
compiler.misc.unchecked.clash.with UncheckedClash.java
compiler.misc.unchecked.implement UncheckedImplement.java
compiler.misc.unchecked.override OverrideUncheckedReturn.java
compiler.misc.unexpected.ret.val UnexpectedReturnValue.java
compiler.misc.unnamed.package UnnamedPackage.java
compiler.misc.varargs.argument.mismatch VarargsArgumentMismatch.java
compiler.misc.varargs.clash.with VarargsClash.java
compiler.misc.varargs.implement VarargsImplement.java
compiler.misc.varargs.override OverrideVarargsExtra.java, OverrideVarargsMissing.java, VarargsOverride.java
compiler.misc.varargs.trustme.on.non.varargs.meth TrustMeOnNonVarargsMeth.java
compiler.misc.varargs.trustme.on.reifiable.varargs TrustMeOnReifiableVarargsParam.java
compiler.misc.varargs.trustme.on.virtual.varargs TrustMeOnVirtualMethod.java
compiler.misc.verbose.checking.attribution Verbose.java
compiler.misc.verbose.classpath Verbose.java
compiler.misc.verbose.loading Verbose.java
compiler.misc.verbose.parsing.done Verbose.java
compiler.misc.verbose.parsing.started Verbose.java
compiler.misc.verbose.sourcepath Verbose.java
compiler.misc.verbose.total Verbose.java
compiler.misc.verbose.wrote.file Verbose.java
compiler.misc.where.captured WhereCaptured.java
compiler.misc.where.captured.1 WhereCaptured1.java
compiler.misc.where.description.captured.1 WhereCaptured.java, WhereCaptured1.java
compiler.misc.where.description.intersection WhereIntersection.java
compiler.misc.where.description.typevar Error.java, WhereCaptured.java, WhereCaptured1.java, WhereFreshTvar.java
compiler.misc.where.description.typevar.1 WhereTypeVar.java
compiler.misc.where.fresh.typevar WhereFreshTvar.java
compiler.misc.where.intersection WhereIntersection.java
compiler.misc.where.typevar Error.java, WhereCaptured.java, WhereCaptured1.java, WhereTypeVar.java
compiler.misc.x.print.processor.info PrintProcessorInfo
compiler.misc.x.print.rounds PrintRounds
compiler.note.compressed.diags CompressedDiags.java
compiler.note.deferred.method.inst DeferredMethodInst.java
compiler.note.deprecated.filename DeprecatedFilename.java
compiler.note.deprecated.filename.additional DeprecatedFilenameAdditional.java
compiler.note.deprecated.plural DeprecatedPlural
compiler.note.deprecated.plural.additional DeprecatedPluralAdditional
compiler.note.deprecated.recompile DeprecatedFilename.java, DeprecatedPlural
compiler.note.lambda.stat LambdaStat.java
compiler.note.mref.stat MrefStat.java
compiler.note.mref.stat.1 MrefStat1.java
compiler.note.note BadEntity.java, BadGreaterThan.java, BadInlineTag.java, CompressedDiags.java, GreaterThanExpected.java, MalformedHTML.java, MissingSemicolon.java, NoContent.java, NoTagName.java, Note.java, RefBadParens.java, RefIdentifierExpected.java, RefSyntaxError.java, RefUnexpectedInput.java, UnexpectedContent.java, UnterminatedInlineTag.java, UnterminatedSignature.java
compiler.note.potential.lambda.found PotentialLambdaFound.java
compiler.note.proc.messager BadEntity.java, BadGreaterThan.java, BadInlineTag.java, GreaterThanExpected.java, MalformedHTML.java, MissingSemicolon.java, NoContent.java, NoTagName.java, NoteProcMessager, RefBadParens.java, RefIdentifierExpected.java, RefSyntaxError.java, RefUnexpectedInput.java, UnexpectedContent.java, UnterminatedInlineTag.java, UnterminatedSignature.java
compiler.note.sunapi.filename SunApiFilename.java
compiler.note.sunapi.filename.additional SunApiFilenameAdditional.java
compiler.note.sunapi.plural SunApiPlural
compiler.note.sunapi.plural.additional SunApiPluralAdditional
compiler.note.sunapi.recompile SunApiFilename.java, SunApiPlural
compiler.note.unchecked.filename Note.java, UncheckedFilename.java
compiler.note.unchecked.filename.additional UncheckedFilenameAdditional.java
compiler.note.unchecked.plural UncheckedPlural
compiler.note.unchecked.plural.additional UncheckedPluralAdditional
compiler.note.unchecked.recompile Note.java, UncheckedFilename.java, UncheckedPlural
compiler.note.verbose.resolve.multi ApplicableMethodFound.java, ApplicableMethodFound1.java, DeferredMethodInst.java, PartialInstSig.java, VerboseResolveMulti.java
compiler.note.verbose.resolve.multi.1 NotApplicableMethodFound.java, VerboseResolveMulti1.java
compiler.warn.assert.as.identifier AssertAsIdentifier.java
compiler.warn.auxiliary.class.accessed.from.outside.of.its.source.file AuxiliaryClassWarning
compiler.warn.constant.SVUID ConstantSVUID.java
compiler.warn.diamond.redundant.args DiamondRedundantArgs.java
compiler.warn.diamond.redundant.args.1 DiamondRedundantArgs1.java
compiler.warn.dir.path.element.not.found DirPathElementNotFound.java
compiler.warn.div.zero DivZero.java
compiler.warn.empty.if EmptyIf.java
compiler.warn.enum.as.identifier EnumAsIdentifier.java
compiler.warn.finally.cannot.complete FinallyCannotComplete.java
compiler.warn.forward.ref WarnForwardRef.java
compiler.warn.has.been.deprecated DeprecatedFilenameAdditional.java, DeprecatedPluralAdditional, HasBeenDeprecated.java
compiler.warn.improper.SVUID ImproperSVUID.java
compiler.warn.inexact.non-varargs.call InexactVarargsCall.java
compiler.warn.lintOption CountWarn.java, CountWarnPlural.java, Error.java
compiler.warn.long.SVUID LongSVUID.java
compiler.warn.missing.SVUID AnonymousClass.java, MissingSVUID.java
compiler.warn.missing.deprecated.annotation MissingDeprecatedAnnotation.java
compiler.warn.override.unchecked.ret OverrideUncheckedReturn.java, UncheckedClash.java, UncheckedImplement.java
compiler.warn.override.unchecked.thrown OverrideUncheckedThrown.java
compiler.warn.override.varargs.extra OverrideVarargsExtra.java, VarargsClash.java, VarargsImplement.java, VarargsOverride.java
compiler.warn.override.varargs.missing OverrideVarargsMissing.java
compiler.warn.path.element.not.found PathElementNotFound.java
compiler.warn.pkg-info.already.seen PackageInfoAlreadySeen
compiler.warn.possible.fall-through.into.case PossibleFallThrough.java
compiler.warn.prob.found.req CountWarn.java, CountWarnPlural.java, UncheckedAssign.java, UncheckedCast.java, UncheckedFilenameAdditional.java, UncheckedMethodInvocation.java, UncheckedPluralAdditional
compiler.warn.proc.annotations.without.processors AnnosWithoutProcessors
compiler.warn.proc.file.create.last.round ProcFileCreateLastRound
compiler.warn.proc.file.reopening ProcFileReopening
compiler.warn.proc.illegal.file.name ProcIllegalFileName
compiler.warn.proc.malformed.supported.string MalformedSupported
compiler.warn.proc.messager WarnProcMessager
compiler.warn.proc.package.does.not.exist ProcPackageDoesNotExist
compiler.warn.proc.proc-only.requested.no.procs ProcOnlyNoProcs.java
compiler.warn.proc.processor.incompatible.source.version ProcIncompatibleSourceVersion
compiler.warn.proc.suspicious.class.name ProcSuspiciousClassName
compiler.warn.proc.type.recreate ProcTypeRecreate
compiler.warn.proc.unclosed.type.files ProcUnclosedTypeFiles
compiler.warn.proc.unmatched.processor.options UnmatchedProcessorOptions
compiler.warn.proc.use.implicit ProcUseImplicit
compiler.warn.proc.use.proc.or.implicit ProcUseProcOrImplicit
compiler.warn.raw.class.use Error.java, RawClassUse.java, WarningAndWerror.java
compiler.warn.redundant.cast RedundantCast.java
compiler.warn.self.ref WarnSelfRef.java
compiler.warn.source.no.bootclasspath DuplicateAnnotation.java, SourceNoBootclasspath.java, TypeAnnotationsNotSupported.java
compiler.warn.static.not.qualified.by.type StaticNotQualifiedByType.java
compiler.warn.sun.proprietary SunApiFilenameAdditional.java, SunApiPluralAdditional, SunProprietary.java
compiler.warn.synthetic.name.conflict WarnSyntheticNameConflict.java
compiler.warn.try.explicit.close.call ResourceClosed.java
compiler.warn.try.resource.not.referenced ResourceNotReferenced.java
compiler.warn.try.resource.throws.interrupted.exc TryResourceThrowsInterruptedExc.java
compiler.warn.unchecked.assign.to.var UncheckedAssignToVar.java
compiler.warn.unchecked.call.mbr.of.raw.type UncheckedCall.java
compiler.warn.unchecked.generic.array.creation UncheckedGenericArrayCreation.java
compiler.warn.unchecked.meth.invocation.applied UncheckedMethodInvocation.java
compiler.warn.unchecked.varargs.non.reifiable.type UncheckedGenericArrayCreation.java, VarargsNonReifiableType.java
compiler.warn.underscore.as.identifier UnderscoreAsIdentifier.java
compiler.warn.unreachable.catch UnreachableCatch.java
compiler.warn.unreachable.catch.1 UnreachableCatch1.java
compiler.warn.varargs.redundant.trustme.anno TrustMeOnReifiableVarargsParam.java
compiler.warn.varargs.unsafe.use.varargs.param UnsafeUseOfVarargsParam.java
compiler.warn.warning CountWarn.java, CountWarnPlural.java, Error.java

AbstractCantBeAccessed.java

Copyright, Info

abstract class Base { abstract void m(); } class AbstractCantBeAccessed extends Base { void m() { super.m(); } }

Output:

examples/AbstractCantBeAccessed.java:32: error: abstract method m() in Base cannot be accessed directly super.m(); ^ 1 error

AbstractCantBeInstantiated.java

Copyright, Info

class AbstractCantBeInstantiated { abstract class C { } void m() { new C(); } }

Output:

examples/AbstractCantBeInstantiated.java:30: error: AbstractCantBeInstantiated.C is abstract; cannot be instantiated new C(); ^ 1 error

AbstractMethodCantHaveBody.java

Copyright, Info

abstract class AbstractMethodCantHaveBody { abstract void m() { } }

Output:

examples/AbstractMethodCantHaveBody.java:27: error: abstract methods cannot have a body abstract void m() { } ^ 1 error

AlreadyDefined.java

Copyright, Info

class X { int i; int i; }

Output:

examples/AlreadyDefined.java:28: error: variable i is already defined in class X int i; ^ 1 error

AlreadyDefinedClinit.java

Copyright, Info

class AlreadyDefinedClinit { static { int i; int i; } }

Output:

examples/AlreadyDefinedClinit.java:29: error: variable i is already defined in static initializer of class AlreadyDefinedClinit int i; ^ 1 error

AlreadyDefinedImport.java

Copyright, Info

import java.awt.List; import java.util.List; class AlreadyDefinedImport { }

Output:

examples/AlreadyDefinedImport.java:27: error: java.awt.List is already defined in a single-type import import java.util.List; ^ 1 error

AlreadyDefinedStaticImport

AlreadDefinedStaticImport.java
Copyright, Info

import static p.E1.A; import static p.E2.A;

p/E1.java
Copyright

package p; public enum E1 { A, B, C}

p/E2.java
Copyright

package p; public enum E2 { A, B, C }

Output:

examples/AlreadyDefinedStaticImport/AlreadDefinedStaticImport.java:26: error: A is already defined in a static single-type import import static p.E1.A; ^ 1 error

AnnoNotApplicable.java

Copyright, Info

import java.lang.annotation.*; @Target(ElementType.METHOD) @interface Anno { } @Anno() class AnnoNotApplicable { }

Output:

examples/AnnoNotApplicable.java:32: error: annotation type not applicable to this kind of declaration @Anno() ^ 1 error

AnnoNotValidForType.java

Copyright, Info

@interface Anno { int value(); } @Anno(@Deprecated) class AnnoNotValueForType { }

Output:

examples/AnnoNotValidForType.java:30: error: annotation not valid for a value of type int @Anno(@Deprecated) ^ 1 error

AnnoValueMustBeAnnotation.java

Copyright, Info

@interface Anno1 { String value(); } @interface Anno2 { Anno1 value(); } @Anno2("3") class AnnoValueMustBeAnnotation { }

Output:

examples/AnnoValueMustBeAnnotation.java:34: error: annotation value must be an annotation @Anno2("3") ^

AnnoValueMustBeClassLiteral.java

Copyright, Info

@interface Anno { Class value(); } @Anno(Class.forName("java.lang.Object")) class AnnoValueMustBeClassLiteral { }

Output:

examples/AnnoValueMustBeClassLiteral.java:30: error: annotation value must be a class literal @Anno(Class.forName("java.lang.Object")) ^ 1 error

AnnosWithoutProcessors

AnnosWithoutProcessors.java
Copyright, Info

@interface Anno { } @Anno class AnnosWithoutProcessors { }

processors/AnnoProc.java
Copyright

import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; @SupportedAnnotationTypes("NotAnno") public class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { return true; } public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } }

Output:

warning: No processor claimed any of these annotations: Anno 1 warning

AnnotationMissingValue.java

Copyright, Info

@interface Anno { String value(); } @Anno class AnnotationMissingValue { }

Output:

examples/AnnotationMissingValue.java:30: error: annotation Anno is missing value for the attribute value @Anno ^ 1 error

AnnotationMissingValues1.java

Copyright, Info

@interface Anno { String a(); String b(); } @Anno class AnnotationMissingValue { }

Output:

examples/AnnotationMissingValues1.java:31: error: annotation Anno is missing values for attributes a,b @Anno ^ 1 error

AnnotationMustBeNameValue.java

Copyright, Info

@interface Anno { String name() default "anon"; String address() default "here"; } @Anno(name == "fred", address = "there") class X { }

Output:

examples/AnnotationMustBeNameValue.java:31: error: annotation values must be of the form 'name=value' @Anno(name == "fred", address = "there") ^ 1 error

AnnotationsNotSupported.java

Copyright, Info

@Deprecated class AnnotationsNotSupported { }

Output:

examples/AnnotationsNotSupported.java:27: error: annotations are not supported in -source 1.4 @Deprecated ^ (use -source 5 or higher to enable annotations) 1 error

AnonClassImplInterfaceNoArgs.java

Copyright, Info

class AnonClassInterfaceNoArgs { Runnable r = new Runnable(3) { public void run() { } }; }

Output:

examples/AnonClassImplInterfaceNoArgs.java:27: error: anonymous class implements interface; cannot have arguments Runnable r = new Runnable(3) { ^ 1 error

AnonClassImplInterfaceNoQualForNew.java

Copyright, Info

class AnonClassImplInterfaceNoQualForNew { interface Intf {} AnonClassImplInterfaceNoQualForNew x; Object o = x.new Intf() { }; }

Output:

examples/AnonClassImplInterfaceNoQualForNew.java:30: error: anonymous class implements interface; cannot have qualifier for new Object o = x.new Intf() { }; ^ 1 error

AnonClassImplInterfaceNoTypeArgs.java

Copyright, Info

class AnonClassInterfaceNoArgs { Runnable r = new<Integer> Runnable() { public void run() { } }; }

Output:

examples/AnonClassImplInterfaceNoTypeArgs.java:27: error: anonymous class implements interface; cannot have type arguments Runnable r = new<Integer> Runnable() { ^ 1 error

AnonymousClass.java

Copyright, Info

class AnonymousClass { Exception m() { return new Exception() { }; } }

Output:

examples/AnonymousClass.java:31: warning: [serial] serializable class <anonymous AnonymousClass$1> has no definition of serialVersionUID return new Exception() { }; ^ 1 warning

ApplicableMethodFound.java

Copyright, Info

class ApplicableMethodFound { void m() {} { m(); } }

Output:

examples/ApplicableMethodFound.java:32: Note: resolving method m in type ApplicableMethodFound to candidate 0 { m(); } ^ phase: BASIC with actuals: no arguments with type-args: no arguments candidates: #0 applicable method found: m()

ApplicableMethodFound1.java

Copyright, Info

class ApplicableMethodFound1 { <X> void m(X x) {} { m(1); } }

Output:

examples/ApplicableMethodFound1.java:33: Note: resolving method m in type ApplicableMethodFound1 to candidate 0 { m(1); } ^ phase: BOX with actuals: int with type-args: no arguments candidates: #0 applicable method found: <X>m(X) (partially instantiated to: (Integer)void) where X is a type-variable: X extends Object declared in method <X>m(X)

ArrayAndReceiver.java

Copyright, Info

class ArrayAndReceiver { void m(ArrayAndReceiver this[]) { } }

Output:

examples/ArrayAndReceiver.java:30: error: legacy array notation not allowed on receiver parameter void m(ArrayAndReceiver this[]) { } ^ examples/ArrayAndReceiver.java:30: error: illegal start of type void m(ArrayAndReceiver this[]) { } ^ examples/ArrayAndReceiver.java:30: error: <identifier> expected void m(ArrayAndReceiver this[]) { } ^ examples/ArrayAndReceiver.java:30: error: ';' expected void m(ArrayAndReceiver this[]) { } ^ examples/ArrayAndReceiver.java:31: error: class, interface, or enum expected } ^ 5 errors

ArrayAndVarargs.java

Copyright, Info

class ArrayAndVarags { void m(int[] array) { } void m(int... args) { } }

Output:

examples/ArrayAndVarargs.java:28: error: cannot declare both m(int...) and m(int[]) in ArrayAndVarags void m(int... args) { } ^ 1 error

ArrayDimMissing.java

Copyright, Info

class ArrayDimMissing { int[] array = new int[]; }

Output:

examples/ArrayDimMissing.java:27: error: array dimension missing int[] array = new int[]; ^ 1 error

ArrayRequired.java

Copyright, Info

class X { int i; int j = i[0]; }

Output:

examples/ArrayRequired.java:28: error: array required, but int found int j = i[0]; ^ 1 error

AssertAsIdentifier.java

Copyright, Info

class AssertAsIdentifier { int assert; }

Output:

examples/AssertAsIdentifier.java:28: warning: as of release 1.4, 'assert' is a keyword, and may not be used as an identifier int assert; ^ (use -source 1.4 or higher to use 'assert' as a keyword) 1 warning

AssertAsIdentifier2.java

Copyright, Info

class AssertAsIdentifier { int assert; }

Output:

examples/AssertAsIdentifier2.java:27: error: as of release 1.4, 'assert' is a keyword, and may not be used as an identifier int assert; ^ (use -source 1.3 or lower to use 'assert' as an identifier) 1 error

AttrMustBeConstant.java

Copyright, Info

@interface Anno { String value(); } @Anno(System.getProperty("user.dir")) class AttrMustBeConstant { }

Output:

examples/AttrMustBeConstant.java:30: error: attribute value must be constant @Anno(System.getProperty("user.dir")) ^ 1 error

AuxiliaryClassWarning

ClassUsingAuxiliary.java
Copyright, Info

class ClassUsingAuxiliary { AuxiliaryClass ahem; }

ClassWithAuxiliary.java
Copyright

class ClassWithAuxiliaryClass { } // Auxiliary class that cannot be found through implicit compilation. class AuxiliaryClass { }

Output:

examples/AuxiliaryClassWarning/ClassUsingAuxiliary.java:28: warning: auxiliary class AuxiliaryClass in examples/AuxiliaryClassWarning/ClassWithAuxiliary.java should not be accessed from outside its own source file AuxiliaryClass ahem; ^ 1 warning

BadArgTypesInLambda.java

Copyright, Info

class BadArgTypesInLambda { interface SAM { void m(Integer i); } void g(SAM s) { } void test() { g(x->{ String s = x; }); } }

Output:

examples/BadArgTypesInLambda.java:39: error: method g in class BadArgTypesInLambda cannot be applied to given types; g(x->{ String s = x; }); ^ required: SAM found: (x)->{ Str[...] x; } reason: argument mismatch; cannot type-check lambda expression with inferred parameter types inferred types: Integer 1 error

BadEntity.java

Copyright, Info

/** & */ class BadEntity { }

Output:

Note: bad HTML entity

BadFunctionalIntfAnno.java

Copyright, Info

@FunctionalInterface class BadFunctionalIntfAnno { }

Output:

examples/BadFunctionalIntfAnno.java:27: error: Unexpected @FunctionalInterface annotation @FunctionalInterface ^ BadFunctionalIntfAnno is not a functional interface 1 error

BadGreaterThan.java

Copyright, Info

/** > */ class BadGreaterThan { }

Output:

Note: bad use of '>'

BadInlineTag.java

Copyright, Info

/** @inheritDoc */ class BadInlineTag { }

Output:

Note: incorrect use of inline tag

BadSourceFileHeader

BadSourceFileHeader.java
Copyright, Info

class BadSourceFileHeader { p.A a; }

sourcepath/p/A.java
Copyright

package q; class A { }

Output:

examples/BadSourceFileHeader/BadSourceFileHeader.java:29: error: cannot access A p.A a; ^ bad source file: examples/BadSourceFileHeader/sourcepath/p/A.java file does not contain class p.A Please remove or make sure it appears in the correct subdirectory of the sourcepath.

BreakOutsideSwitchLoop.java

Copyright, Info

class BreakOutsideSwitchLoop { void m() { break; } }

Output:

examples/BreakOutsideSwitchLoop.java:28: error: break outside switch or loop break; ^ 1 error

CallMustBeFirst.java

Copyright, Info

class CallMustBeFirst { CallMustBeFirst() { int i = 0; super(); } }

Output:

examples/CallMustBeFirst.java:29: error: call to super must be first statement in constructor super(); ^ 1 error

CannotCreateArrayWithDiamond.java

Copyright, Info

class CannotCreateArrayWithDiamond { Object[] array = new Object<>[3]; }

Output:

examples/CannotCreateArrayWithDiamond.java:27: error: cannot create array with '<>' Object[] array = new Object<>[3]; ^ 1 error

CannotCreateArrayWithTypeArgs.java

Copyright, Info

class X { Object[] array = new<Integer> Object[3]; }

Output:

examples/CannotCreateArrayWithTypeArgs.java:27: error: cannot create array with type arguments Object[] array = new<Integer> Object[3]; ^ 1 error

CantAccessInnerClsConstr.java

Copyright, Info

class CantAccessInnerClsConstructor { interface SAM { Outer m(); } class Outer { } static void test() { SAM s = Outer::new; } }

Output:

examples/CantAccessInnerClsConstr.java:37: error: incompatible types: invalid constructor reference SAM s = Outer::new; ^ cannot access constructor Outer() an enclosing instance of type CantAccessInnerClsConstructor is not in scope 1 error

CantAnnotateNestedType.java

Copyright, Info

import java.lang.annotation.*; class CantAnnotateStaticClass { @Target(ElementType.TYPE_USE) @interface A {} interface Outer { interface Inner {} } // Error: @A Outer.Inner f; // OK: @A Outer g; }

Output:

error: nested type cannot be annotated 1 error

CantAnnotateStaticClass.java

Copyright, Info

import java.lang.annotation.*; class CantAnnotateStaticClass { @Target(ElementType.TYPE_USE) @interface A {} static class Outer { class Inner {} } // Error: @A Outer.Inner f; // OK: @A Outer g; }

Output:

examples/CantAnnotateStaticClass.java:37: error: enclosing static nested class cannot be annotated @A Outer.Inner f; ^ 1 error

CantApplyDiamond.java

Copyright, Info

class CantApplyDiamond<T extends Number> { CantApplyDiamond(T t) { } <U> CantApplyDiamond(T t, U u) { } void m() { CantApplyDiamond<?> x = new CantApplyDiamond<>(""); } }

Output:

examples/CantApplyDiamond.java:32: error: cannot infer type arguments for CantApplyDiamond<> CantApplyDiamond<?> x = new CantApplyDiamond<>(""); ^ 1 error

CantApplyDiamond1.java

Copyright, Info

class CantApplyDiamond1<X> { CantApplyDiamond1(CantApplyDiamond1<? super X> lz) { } void test(CantApplyDiamond1<Integer> li) { CantApplyDiamond1<String> ls = new CantApplyDiamond1<>(li); } }

Output:

examples/CantApplyDiamond1.java:34: error: incompatible types: cannot infer type arguments for CantApplyDiamond1<> CantApplyDiamond1<String> ls = new CantApplyDiamond1<>(li); ^ reason: inference variable X has incompatible bounds equality constraints: String upper bounds: Integer,Object where X is a type-variable: X extends Object declared in class CantApplyDiamond1 1 error

CantApplySymbolFragment.java

Copyright, Info

class CantApplySymbolFragment { interface SAM { void m(Integer u); } static void f(String s) { } void test() { SAM s = CantApplySymbolFragment::f; } }

Output:

examples/CantApplySymbolFragment.java:39: error: incompatible types: invalid method reference SAM s = CantApplySymbolFragment::f; ^ incompatible types: Integer cannot be converted to String 1 error

CantApplySymbolsFragment.java

Copyright, Info

class CantApplySymbolsFragment { interface SAM { void m(Integer u); } static void f() { } static void f(String s) { } void test() { SAM s = CantApplySymbolsFragment::f; } }

Output:

examples/CantApplySymbolsFragment.java:43: error: incompatible types: invalid method reference SAM s = CantApplySymbolsFragment::f; ^ method f in class CantApplySymbolsFragment cannot be applied to given types required: no arguments found: Integer reason: actual and formal argument lists differ in length 1 error

CantAssignToFinal.java

Copyright, Info

class CantAssignToFinal { final int i = 0; void m() { i = 3; } }

Output:

examples/CantAssignToFinal.java:30: error: cannot assign a value to final variable i i = 3; ^ 1 error

CantDeref.java

Copyright, Info

class X { int m(int i) { return i.x; } }

Output:

examples/CantDeref.java:28: error: int cannot be dereferenced return i.x; ^ 1 error

CantExtendIntfAnno.java

Copyright, Info

@interface Anno { } @interface CantExtendIntfAnno extends Anno { }

Output:

examples/CantExtendIntfAnno.java:28: error: 'extends' not allowed for @interfaces @interface CantExtendIntfAnno extends Anno { } ^ 1 error

CantImplement.java

Copyright, Info

interface Interface { void m(); } class CantImplement implements Interface { void m() { } }

Output:

examples/CantImplement.java:32: error: m() in CantImplement cannot implement m() in Interface void m() { } ^ attempting to assign weaker access privileges; was public 1 error

CantInheritDiffArg.java

Copyright, Info

import java.util.*; class CantInheritDiffArg extends ArrayList<String> implements List<Integer> { }

Output:

examples/CantInheritDiffArg.java:28: error: List cannot be inherited with different arguments: <java.lang.Integer> and <java.lang.String> class CantInheritDiffArg extends ArrayList<String> implements List<Integer> { } ^ 1 error

CantRefBeforeConstr.java

Copyright, Info

class Base { Base(int i) { } } class CantRefBeforeConstr extends Base { int i; CantRefBeforeConstr() { super(i); } }

Output:

examples/CantRefBeforeConstr.java:34: error: cannot reference i before supertype constructor has been called super(i); ^ 1 error

CantRefNonEffectivelyFinalVar.java

Copyright, Info

class CantRefNonEffectivelyFinalVar { void test() { int i = 0; new Object() { int j = i; }; i = 2; } interface SAM { void m(); } void test2() { int i = 0; SAM s = ()-> { int j = i; }; i++; } }

Output:

examples/CantRefNonEffectivelyFinalVar.java:31: error: local variables referenced from an inner class must be final or effectively final new Object() { int j = i; }; ^ examples/CantRefNonEffectivelyFinalVar.java:41: error: local variables referenced from a lambda expression must be final or effectively final SAM s = ()-> { int j = i; }; ^ 2 errors

CantResolve.java

Copyright, Info

class CantResolve { Object o = new Object() { int i = f; }; }

Output:

examples/CantResolve.java:28: error: cannot find symbol int i = f; ^ symbol: variable f 1 error

CantResolveArgs.java

Copyright, Info

import java.util.*; class CantResolveArgs { void m() { new Runnable() { { unknown(); } public void run() { } }; } }

Output:

examples/CantResolveArgs.java:31: error: cannot find symbol { unknown(); } ^ symbol: method unknown() 1 error

CantResolveArgsParams.java

Copyright, Info

class CantResolveArgsParams { Object o = new Object() { { this.<Integer,Double>m2(1, ""); } }; }

Output:

examples/CantResolveArgsParams.java:28: error: cannot find symbol { this.<Integer,Double>m2(1, ""); } ^ symbol: method <Integer,Double>m2(int,String) 1 error

CantResolveLocation.java

Copyright, Info

class CantResolveLocation { Unknown y; }

Output:

examples/CantResolveLocation.java:28: error: cannot find symbol Unknown y; ^ symbol: class Unknown location: class CantResolveLocation 1 error

CantResolveLocationArgs.java

Copyright, Info

class X { void m() { unknown(1); } }

Output:

examples/CantResolveLocationArgs.java:29: error: cannot find symbol unknown(1); ^ symbol: method unknown(int) location: class X 1 error

CantResolveLocationArgsFragment.java

Copyright, Info

class CantResolveLocationArgsFragment { interface SAM { void m(Integer u); } void test() { SAM s = CantResolveLocationArgsFragment::f; } }

Output:

examples/CantResolveLocationArgsFragment.java:35: error: invalid method reference SAM s = CantResolveLocationArgsFragment::f; ^ cannot find symbol symbol: method f(Integer) location: class CantResolveLocationArgsFragment 1 error

CantResolveLocationArgsParams.java

Copyright, Info

import java.util.*; class X { void m() { Object o = List.<String>unknown(); } }

Output:

examples/CantResolveLocationArgsParams.java:31: error: cannot find symbol Object o = List.<String>unknown(); ^ symbol: method <String>unknown() location: interface List 1 error

CantResolveLocationArgsParamsFragment.java

Copyright, Info

class CantResolveLocationArgsParamsFragment { interface SAM { void m(Integer u); } void test() { SAM s = CantResolveLocationArgsParamsFragment::<String>f; } }

Output:

examples/CantResolveLocationArgsParamsFragment.java:35: error: invalid method reference SAM s = CantResolveLocationArgsParamsFragment::<String>f; ^ cannot find symbol symbol: method <String>f(Integer) location: class CantResolveLocationArgsParamsFragment 1 error

CatchWithoutTry.java

Copyright, Info

class CatchWithoutTry { void m() { catch (Exception e) { } } }

Output:

examples/CatchWithoutTry.java:28: error: 'catch' without 'try' catch (Exception e) { ^ 1 error

ClashesWith.java

Copyright, Info

interface Base { int m(); } interface ClashesWith extends Base { String m(); }

Output:

examples/ClashesWith.java:32: error: m() in ClashesWith clashes with m() in Base String m(); ^ return type String is not compatible with int 1 error

ClassCantWrite.java

Copyright, Info

class ClassCantWrite { }

Output:

examples/ClassCantWrite.java:27: error: error while writing ClassCantWrite: FileManager: Can't write class ClassCantWrite { } ^ 1 error

ClassPublicInFile.java

Copyright, Info

public class C { }

Output:

examples/ClassPublicInFile.java:26: error: class C is public, should be declared in a file named C.java public class C { } ^ 1 error

CompressedDiags.java

Copyright, Info

class CompressedDiags { void m(String s) { } void test() { m(1); } }

Output:

examples/CompressedDiags.java:37: error: incompatible types: int cannot be converted to String m(1); ^ Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 1 error

ConcreteInheritanceConflict.java

Copyright, Info

class Base<T> { void m(T t) { } void m(String s) { } } class ConcreteInheritanceConflict extends Base<String> { }

Output:

examples/ConcreteInheritanceConflict.java:31: error: methods m(T) from Base<String> and m(String) from Base<String> are inherited with the same signature class ConcreteInheritanceConflict extends Base<String> { } ^ where T is a type-variable: T extends Object declared in class Base 1 error

ConditionalTargetCantBeVoid.java

Copyright, Info

class ConditionalTargetCantBeVoid { interface SAM { void m(); } void test(boolean cond, Object o1, Object o2) { SAM s = ()-> cond ? o1 : o2; } }

Output:

examples/ConditionalTargetCantBeVoid.java:35: error: incompatible types: bad return type in lambda expression SAM s = ()-> cond ? o1 : o2; ^ target-type for conditional expression cannot be void 1 error

ConstExprRequired.java

Copyright, Info

class ConstExprRequired { int i = 3; String m(int arg) { switch (arg) { case 0: return "zero"; case 1: return "one"; case i: return "i"; } } }

Output:

examples/ConstExprRequired.java:33: error: constant expression required case i: return "i"; ^ 1 error

ConstantSVUID.java

Copyright, Info

import java.io.Serializable; class ConstantSVUID implements Serializable { private static final long serialVersionUID = Integer.parseInt("0"); }

Output:

examples/ConstantSVUID.java:30: warning: [serial] serialVersionUID must be constant in class ConstantSVUID private static final long serialVersionUID = Integer.parseInt("0"); ^ 1 warning

ContinueOutsideLoop.java

Copyright, Info

class ContinueOutsideLoop { void m() { continue; } }

Output:

examples/ContinueOutsideLoop.java:28: error: continue outside of loop continue; ^ 1 error

CountError.java

Copyright, Info

class CountError { void m() { throw new Exception(); } }

Output:

examples/CountError.java:30: error: unreported exception Exception; must be caught or declared to be thrown void m() { throw new Exception(); } ^ 1 error

CountErrorPlural.java

Copyright, Info

class CountErrorPlural { void m1() { throw new Exception(); } void m2() { throw new Exception(); } }

Output:

examples/CountErrorPlural.java:30: error: unreported exception Exception; must be caught or declared to be thrown void m1() { throw new Exception(); } ^ examples/CountErrorPlural.java:31: error: unreported exception Exception; must be caught or declared to be thrown void m2() { throw new Exception(); } ^ 2 errors

CountWarn.java

Copyright, Info

import java.util.*; class CountWarn { List<String> list = new ArrayList(); }

Output:

examples/CountWarn.java:35: warning: [unchecked] unchecked conversion List<String> list = new ArrayList(); ^ required: List<String> found: ArrayList 1 warning

CountWarnPlural.java

Copyright, Info

import java.util.*; class CountWarn { List<String> list1 = new ArrayList(); List<String> list2 = new ArrayList(); }

Output:

examples/CountWarnPlural.java:35: warning: [unchecked] unchecked conversion List<String> list1 = new ArrayList(); ^ required: List<String> found: ArrayList examples/CountWarnPlural.java:36: warning: [unchecked] unchecked conversion List<String> list2 = new ArrayList(); ^ required: List<String> found: ArrayList 2 warnings

CyclicAnnoElement.java

Copyright, Info

@interface X { X value(); }

Output:

examples/CyclicAnnoElement.java:27: error: cyclic annotation element type X value(); ^ 1 error

CyclicInference.java

Copyright, Info

class CyclicInference { interface SAM<X> { void m(X x); } <Z> void g(SAM<Z> sz) { } void test() { g(x-> {}); } }

Output:

examples/CyclicInference.java:35: error: incompatible types: Cannot instantiate inference variables Z because of an inference loop g(x-> {}); ^ where Z is a type-variable: Z extends Object declared in method <Z>g(SAM<Z>) 1 error

CyclicInheritance.java

Copyright, Info

class CyclicInheritance extends CyclicInheritance { }

Output:

examples/CyclicInheritance.java:26: error: cyclic inheritance involving CyclicInheritance class CyclicInheritance extends CyclicInheritance { } ^ 1 error

DefaultAllowedInIntfAnnotationMember.java

Copyright, Info

interface DefaultAllowedInIntfAnnotationMember { String value() default ""; }

Output:

examples/DefaultAllowedInIntfAnnotationMember.java:27: error: default value only allowed in an @interface member String value() default ""; ^ 1 error

DefaultMethodNotSupported.java

Copyright, Info

interface DefaultMethodNotSupported { default void m() { } }

Output:

examples/DefaultMethodNotSupported.java:28: error: default methods are not supported in -source 1.7 default void m() { } ^ (use -source 8 or higher to enable default methods) 1 error

DefaultOverridesObjectMember.java

Copyright, Info

interface DefaultOverridesObjectMember { default String toString() { return ""; } }

Output:

examples/DefaultOverridesObjectMember.java:27: error: default method toString in interface DefaultOverridesObjectMember overrides a member of java.lang.Object default String toString() { return ""; } ^ 1 error

DeferredMethodInst.java

Copyright, Info

class DeferredMethodInst { <X> X m() { return null; } { Integer i = m(); } }

Output:

examples/DeferredMethodInst.java:34: Note: resolving method m in type DeferredMethodInst to candidate 0 { Integer i = m(); } ^ phase: BASIC with actuals: no arguments with type-args: no arguments candidates: #0 applicable method found: <X>m() (partially instantiated to: ()Object) where X is a type-variable: X extends Object declared in method <X>m() examples/DeferredMethodInst.java:34: Note: Deferred instantiation of method <X>m() { Integer i = m(); } ^ instantiated signature: ()Integer target-type: Integer where X is a type-variable: X extends Object declared in method <X>m()

DeprecatedFilename.java

Copyright, Info

class DeprecatedFilename { DeprecatedClass d; } @Deprecated class DeprecatedClass { }

Output:

Note: examples/DeprecatedFilename.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details.

DeprecatedFilenameAdditional.java

Copyright, Info

class DeprecatedFilename { DeprecatedClass d; } class DeprecatedFilenameAdditional { DeprecatedClass d; } @Deprecated class DeprecatedClass { }

Output:

examples/DeprecatedFilenameAdditional.java:29: warning: [deprecation] DeprecatedClass in unnamed package has been deprecated DeprecatedClass d; ^ Note: examples/DeprecatedFilenameAdditional.java has additional uses or overrides of a deprecated API. 1 warning

DeprecatedPlural

DeprecatedPlural.java
Copyright, Info

class DeprecatedPlural { DeprecatedClass d; }

DeprecatedClass.java
Copyright

@Deprecated class DeprecatedClass { }

DeprecatedFilename.java
Copyright

class DeprecatedFileName { DeprecatedClass d; }

Output:

Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details.

DeprecatedPluralAdditional

DeprecatedPluralAdditional.java
Copyright, Info

class DeprecatedPluralAdditional { DeprecatedClass d; }

DeprecatedClass.java
Copyright

@Deprecated class DeprecatedClass { }

DeprecatedFilename.java
Copyright

class DeprecatedFileName { DeprecatedClass d; }

DeprecatedPlural.java
Copyright

class DeprecatedPlural { DeprecatedClass d; }

Output:

examples/DeprecatedPluralAdditional/DeprecatedPluralAdditional.java:29: warning: [deprecation] DeprecatedClass in unnamed package has been deprecated DeprecatedClass d; ^ Note: Some input files additionally use or override a deprecated API. 1 warning

DiamondAndAnonClass.java

Copyright, Info

import java.util.*; class DiamondAndAnonClass { void m() { List<String> list = new ArrayList<>() {}; } }

Output:

examples/DiamondAndAnonClass.java:31: error: cannot infer type arguments for ArrayList<E> List<String> list = new ArrayList<>() {}; ^ reason: cannot use '<>' with anonymous inner classes where E is a type-variable: E extends Object declared in class ArrayList 1 error

DiamondAndExplicitParams.java

Copyright, Info

class DiamondAndAnonClass { static class Foo<X> { <Z> Foo() {} } void m() { Foo<String> foo = new <Integer> Foo<>(); } }

Output:

examples/DiamondAndExplicitParams.java:32: error: cannot infer type arguments for Foo<X> Foo<String> foo = new <Integer> Foo<>(); ^ reason: cannot use '<>' with explicit type parameters for constructor where X is a type-variable: X extends Object declared in class Foo 1 error

DiamondNonGeneric.java

Copyright, Info

class DiamondNonGeneric { String s = new String<>("foo"); }

Output:

examples/DiamondNonGeneric.java:28: error: cannot infer type arguments for String String s = new String<>("foo"); ^ reason: cannot use '<>' with non-generic class String 1 error

DiamondNotSupported.java

Copyright, Info

import java.util.*; class DiamondNotSupported { void m() { List<String> list = new ArrayList<>(); } }

Output:

examples/DiamondNotSupported.java:31: error: diamond operator is not supported in -source 1.6 List<String> list = new ArrayList<>(); ^ (use -source 7 or higher to enable diamond operator) 1 error

DiamondRedundantArgs.java

Copyright, Info

class Foo<X> { Foo<String> fs = new Foo<String>(); }

Output:

examples/DiamondRedundantArgs.java:28: warning: redundant type arguments in new expression (use diamond operator instead). Foo<String> fs = new Foo<String>(); ^ 1 warning

DiamondRedundantArgs1.java

Copyright, Info

class Foo<X> { Foo<?> fs = new Foo<String>(); }

Output:

examples/DiamondRedundantArgs1.java:28: warning: redundant type arguments in new expression (use diamond operator instead). Foo<?> fs = new Foo<String>(); ^ explicit: Foo<String> inferred: Foo<Object> 1 warning

DirPathElementNotFound.java

Copyright, Info

class DirPathElementNotFound { }

Output:

warning: [path] bad path element "DoesNotExist": no such directory 1 warning

DivZero.java

Copyright, Info

class DivZero { int m(int a) { return a / 0 ; } }

Output:

examples/DivZero.java:29: warning: [divzero] division by zero return a / 0 ; ^ 1 warning

DoesNotOverride.java

Copyright, Info

abstract class Base { abstract void m(); } class DoesNotOverride extends Base { }

Output:

examples/DoesNotOverride.java:30: error: DoesNotOverride is not abstract and does not override abstract method m() in Base class DoesNotOverride extends Base { } ^ 1 error

DoesntExist.java

Copyright, Info

import DoesntExist.*;

Output:

examples/DoesntExist.java:26: error: package DoesntExist does not exist import DoesntExist.*; ^ 1 error

DotClassExpected.java

Copyright, Info

class DotClassExpected { int f = int[] + 3; }

Output:

examples/DotClassExpected.java:27: error: '.class' expected int f = int[] + 3; ^ 1 error

DuplicateAnnotation.java

Copyright, Info

@interface Anno { } @Anno @Anno class DuplicateAnnotation { }

Output:

warning: [options] bootstrap class path not set in conjunction with -source 1.7 examples/DuplicateAnnotation.java:31: error: duplicate annotation @Anno ^ 1 error 1 warning

DuplicateAnnotationJava8.java

Copyright, Info

@interface Anno { } @Anno @Anno class DuplicateAnnotationJava8 { }

Output:

examples/DuplicateAnnotationJava8.java:29: error: duplicate annotation: the declaration of Anno does not have a valid Repeatable annotation @Anno ^ 1 error

DuplicateAnnotationMemberValue.java

Copyright, Info

@interface Anno { int value(); } @Anno(value=1, value=2) class DuplicateAnnotationMemberValue { }

Output:

examples/DuplicateAnnotationMemberValue.java:30: error: duplicate annotation member value value in Anno @Anno(value=1, value=2) ^ 1 error

DuplicateCaseLabel.java

Copyright, Info

class DuplicateCaseLabel { String m(int arg) { switch (arg) { case 0: return "zero"; case 1: return "one"; case 1: return "one"; } } }

Output:

examples/DuplicateCaseLabel.java:31: error: duplicate case label case 1: return "one"; ^ 1 error

DuplicateClass.java

Copyright, Info

class DuplicateClass { } class DuplicateClass { }

Output:

examples/DuplicateClass.java:28: error: duplicate class: DuplicateClass class DuplicateClass { } ^ 1 error

DuplicateDefaultLabel.java

Copyright, Info

class DuplicateCaseLabel { String m(int arg) { switch (arg) { case 0: return "zero"; case 1: return "one"; default: return "??"; default: return "??"; } } }

Output:

examples/DuplicateDefaultLabel.java:32: error: duplicate default label default: return "??"; ^ 1 error

ElseWithoutIf.java

Copyright, Info

class ElseWithoutIf { void m() { else { } } }

Output:

examples/ElseWithoutIf.java:28: error: 'else' without 'if' else { ^ 1 error

EmptyCharLiteral.java

Copyright, Info

class X { char c = ''; }

Output:

examples/EmptyCharLiteral.java:29: error: empty character literal char c = ''; ^ examples/EmptyCharLiteral.java:29: error: unclosed character literal char c = ''; ^ examples/EmptyCharLiteral.java:31: error: reached end of file while parsing 3 errors

EmptyIf.java

Copyright, Info

class EmptyIf { void m(int a, int b) { if (a == b) ; } }

Output:

examples/EmptyIf.java:29: warning: [empty] empty statement after if if (a == b) ; ^ 1 warning

EnclClassRequired.java

Copyright, Info

class Base { class Nested { } } class EnclClassRequired extends Base.Nested { }

Output:

examples/EnclClassRequired.java:30: error: an enclosing instance that contains Base.Nested is required class EnclClassRequired extends Base.Nested { } ^ 1 error

EnumAnnoValueMustBeEnumConst.java

Copyright, Info

enum E { A, B, C } @interface Anno { E value(); } @Anno(E.valueOf("A")) class EnumAnnoValueMustBeEnumConstant { }

Output:

examples/EnumAnnoValueMustBeEnumConst.java:32: error: an enum annotation value must be an enum constant @Anno(E.valueOf("A")) ^ 1 error

EnumAsIdentifier.java

Copyright, Info

class EnumAsIdentifier { int enum; }

Output:

examples/EnumAsIdentifier.java:28: warning: as of release 5, 'enum' is a keyword, and may not be used as an identifier int enum; ^ (use -source 5 or higher to use 'enum' as a keyword) 1 warning

EnumAsIdentifier2.java

Copyright, Info

class EnumAsIdentifier2 { int enum; }

Output:

examples/EnumAsIdentifier2.java:27: error: as of release 5, 'enum' is a keyword, and may not be used as an identifier int enum; ^ (use -source 1.4 or lower to use 'enum' as an identifier) 1 error

EnumCantBeInstantiated.java

Copyright, Info

class EnumCantBeInstantiated { enum E { A, B, C } E e = new E("a"); }

Output:

examples/EnumCantBeInstantiated.java:29: error: enum types may not be instantiated E e = new E("a"); ^ 1 error

EnumLabelUnqualified.java

Copyright, Info

class EnumLabelUnqualified { enum E { A, B, C }; void m(E e) { switch (e) { case E.A: System.out.println("A"); } } }

Output:

examples/EnumLabelUnqualified.java:32: error: an enum switch case label must be the unqualified name of an enumeration constant case E.A: ^ 1 error

EnumNoFinalize.java

Copyright, Info

enum EnumNoFinalize { A, B, C; public void finalize() { } }

Output:

examples/EnumNoFinalize.java:31: error: enums cannot have finalize methods public void finalize() { } ^ 1 error

EnumNoSubclassing.java

Copyright, Info

class EnumNoSubclassing extends Enum { }

Output:

examples/EnumNoSubclassing.java:26: error: classes cannot directly extend java.lang.Enum class EnumNoSubclassing extends Enum { } ^ 1 error

EnumTypesNotExtensible.java

Copyright, Info

enum E { A, B, C } class EnumTypesNotExtensible extends E { }

Output:

examples/EnumTypesNotExtensible.java:29: error: cannot inherit from final E class EnumTypesNotExtensible extends E { } ^ examples/EnumTypesNotExtensible.java:29: error: enum types are not extensible class EnumTypesNotExtensible extends E { } ^ 2 errors

EnumsMustBeStatic.java

Copyright, Info

class EnumsMustBeStatic { class Nested { enum E { A, B, C } } }

Output:

examples/EnumsMustBeStatic.java:28: error: enum declarations allowed only in static contexts enum E { A, B, C } ^ 1 error

EnumsNotSupported.java

Copyright, Info

enum EnumsNotSupported { A, B, C }

Output:

examples/EnumsNotSupported.java:27: error: enums are not supported in -source 1.4 enum EnumsNotSupported { A, B, C } ^ (use -source 5 or higher to enable enums) 1 error

ErrProcMessager

ErrProcMessager.java
Copyright, Info

class ErrProcMessager { }

processors/AnnoProc.java
Copyright

import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; import javax.tools.*; @SupportedAnnotationTypes("*") public class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { if (renv.processingOver()) { Messager m = processingEnv.getMessager(); m.printMessage(Diagnostic.Kind.ERROR, "Error!"); } return true; } public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } }

Output:

error: Error! 1 error

ErrSyntheticNameConflict.java

Copyright, Info

class ErrSyntheticNameConflict { static class Outer { ErrSyntheticNameConflict this$0 = null; } public class Inner extends Outer { } }

Output:

examples/ErrSyntheticNameConflict.java:32: error: the symbol this$0 conflicts with a compiler-synthesized symbol in Outer public class Inner extends Outer { } ^ 1 error

Error.java

Copyright, Info

import java.util.*; class X { List l; }

Output:

examples/Error.java:40: warning: [rawtypes] found raw type: List List l; ^ missing type arguments for generic class List<E> where E is a type-variable: E extends Object declared in interface List error: warnings found and -Werror specified 1 error 1 warning

ErrorReadingFile.java

Copyright, Info

class ErrorReadingFile { }

Output:

error: error reading examples/ErrorReadingFile.java; FileManager: Can't read 1 error

ExceptAlreadyCaught.java

Copyright, Info

class ExceptAlreadyCaught { void x() throws Exception { } void m() { try { x(); } catch (Exception e) { } catch (Exception e) { } } }

Output:

examples/ExceptAlreadyCaught.java:33: error: exception Exception has already been caught } catch (Exception e) { ^ 1 error

ExceptNeverThrown.java

Copyright, Info

import java.io.*; class ExceptNeverThrown { void m(int i) { try { i++; } catch (IOException e) { } } }

Output:

examples/ExceptNeverThrown.java:32: error: exception IOException is never thrown in body of corresponding try statement } catch (IOException e) { ^ 1 error

Expected2.java

Copyright, Info

int Expected2;

Output:

examples/Expected2.java:27: error: class or interface expected int Expected2; ^ 1 error

Expected3.java

Copyright, Info

int Expected3;

Output:

examples/Expected3.java:26: error: class, interface, or enum expected int Expected3; ^ 1 error

ExplicitParamsDoNotConformToBounds.java

Copyright, Info

class ExplicitParamsDoNotConformToBounds { <X extends Number> void m() {} { this.<String>m(); } }

Output:

examples/ExplicitParamsDoNotConformToBounds.java:29: error: method m in class ExplicitParamsDoNotConformToBounds cannot be applied to given types; { this.<String>m(); } ^ required: no arguments found: no arguments reason: explicit type argument String does not conform to declared bound(s) Number 1 error

FinalParamCantBeAssigned.java

Copyright, Info

class FinalParamCantBeAssigned { void m(final int i) { i++; } }

Output:

examples/FinalParamCantBeAssigned.java:28: error: final parameter i may not be assigned i++; ^ 1 error

FinallyCannotComplete.java

Copyright, Info

class FinallyCannotComplete { void m() { try { } finally { throw new Error(); } } }

Output:

examples/FinallyCannotComplete.java:32: warning: [finally] finally clause cannot complete normally } ^ 1 warning

FinallyWithoutTry.java

Copyright, Info

class FinallyWithoutTry { void m() { finally { } } }

Output:

examples/FinallyWithoutTry.java:28: error: 'finally' without 'try' finally { ^ 1 error

FloatNumberTooLarge.java

Copyright, Info

class FloatNumberTooLarge { float f = 1e9999; }

Output:

examples/FloatNumberTooLarge.java:27: error: floating point number too large float f = 1e9999; ^ 1 error

FloatNumberTooSmall.java

Copyright, Info

class FloatNumberTooSmall { float f = 1e-9999; }

Output:

examples/FloatNumberTooSmall.java:27: error: floating point number too small float f = 1e-9999; ^ 1 error

ForeachBadInitialization.java

Copyright, Info

import java.util.List; class ForeachBadInitialization { void m() { List<String> s = null; for (a : s) {} } }

Output:

examples/ForeachBadInitialization.java:29: error: bad initializer for for-loop for (a : s) {} ^ 1 error

ForeachNotApplicable.java

Copyright, Info

class ForeachNotApplicable { void m(String arg) { for (String a: arg) { System.out.println(a); } } }

Output:

examples/ForeachNotApplicable.java:29: error: for-each not applicable to expression type for (String a: arg) { ^ required: array or java.lang.Iterable found: String 1 error

ForeachNotSupported.java

Copyright, Info

class ForeachNotSupported { void m(String[] args) { for (String a: args) { System.out.println(a); } } }

Output:

examples/ForeachNotSupported.java:29: error: for-each loops are not supported in -source 1.4 for (String a: args) { ^ (use -source 5 or higher to enable for-each loops) 1 error

GenericArrayCreation.java

Copyright, Info

import java.util.*; class GenericArrayCreation<T> { ArrayList<T>[] array = new ArrayList<T>[5]; }

Output:

examples/GenericArrayCreation.java:29: error: generic array creation ArrayList<T>[] array = new ArrayList<T>[5]; ^ 1 error

GenericThrowable.java

Copyright, Info

class GenericThrowable<T> extends Exception { }

Output:

examples/GenericThrowable.java:26: error: a generic class may not extend java.lang.Throwable class GenericThrowable<T> extends Exception { } ^ 1 error

GenericsNotSupported.java

Copyright, Info

class GenericsNotSupported<T> { }

Output:

examples/GenericsNotSupported.java:27: error: generics are not supported in -source 1.4 class GenericsNotSupported<T> { } ^ (use -source 5 or higher to enable generics) 1 error

GreaterThanExpected.java

Copyright, Info

class GreaterThanExpected { /** @param <T */ <T> void m(T t) { } }

Output:

Note: '>' expected

HasBeenDeprecated.java

Copyright, Info

package p; class Test { DeprecatedClass d; } @Deprecated class DeprecatedClass { }

Output:

examples/HasBeenDeprecated.java:30: warning: [deprecation] DeprecatedClass in p has been deprecated DeprecatedClass d; ^ 1 warning

IdentifierExpected.java

Copyright, Info

class IdentifierExpected { long bl = 0BL; }

Output:

examples/IdentifierExpected.java:32: error: binary numbers must contain at least one binary digit long bl = 0BL; ^ examples/IdentifierExpected.java:32: error: <identifier> expected long bl = 0BL; ^ 2 errors

IllegalChar.java

Copyright, Info

class IllegalChar { int i = `; }

Output:

examples/IllegalChar.java:27: error: illegal character: '`' int i = `; ^ 1 error

IllegalComboModifiers.java

Copyright, Info

class IllegalComboModifiers { public private int x; }

Output:

examples/IllegalComboModifiers.java:27: error: illegal combination of modifiers: public and private public private int x; ^ 1 error

IllegalDot.java

Copyright, Info

class X { void m(Object.. args) { } }

Output:

examples/IllegalDot.java:29: error: illegal '.' void m(Object.. args) { } ^ examples/IllegalDot.java:29: error: ';' expected void m(Object.. args) { } ^ examples/IllegalDot.java:29: error: illegal start of type void m(Object.. args) { } ^ examples/IllegalDot.java:29: error: <identifier> expected void m(Object.. args) { } ^ examples/IllegalDot.java:29: error: ';' expected void m(Object.. args) { } ^ 5 errors

IllegalEnumStaticRef.java

Copyright, Info

enum IllegalEnumStaticRef { A() { Object o = B; }, B }

Output:

examples/IllegalEnumStaticRef.java:27: error: illegal reference to static field from initializer A() { Object o = B; }, ^ 1 error

IllegalEscapeChar.java

Copyright, Info

class IllegalEscapeChar { String s = "\!"; }

Output:

examples/IllegalEscapeChar.java:27: error: illegal escape character String s = "\!"; ^ 1 error

IllegalForwardRef.java

Copyright, Info

class IllegalForwardRef { int x = y; int y; }

Output:

examples/IllegalForwardRef.java:27: error: illegal forward reference int x = y; ^ 1 error

IllegalInitializer.java

Copyright, Info

class IllegalInitializer { int i = { 1 }; }

Output:

examples/IllegalInitializer.java:27: error: illegal initializer for int int i = { 1 }; ^ 1 error

IllegalLineEndInCharLit.java

Copyright, Info

class IllegalLineEndInCharLit { char c = ' '; }

Output:

examples/IllegalLineEndInCharLit.java:27: error: illegal line end in character literal char c = ' ^ 1 error

IllegalNonAsciiDigit.java

Copyright, Info

class X { int i = 0\u0660; // Zero followed by Arabic-Indic Digit Zero }

Output:

examples/IllegalNonAsciiDigit.java:27: error: illegal non-ASCII digit int i = 0\u0660; // Zero followed by Arabic-Indic Digit Zero ^ 1 error

IllegalQualNotIcls.java

Copyright, Info

class IllegalQualNotIcls { static class C { } IllegalQualNotIcls x; C c = x.new C() { }; }

Output:

examples/IllegalQualNotIcls.java:30: error: qualified new of static class C c = x.new C() { }; ^ examples/IllegalQualNotIcls.java:30: error: illegal qualifier; C is not an inner class C c = x.new C() { }; ^ 2 errors

IllegalSelfRef.java

Copyright, Info

class IllegalSelfRef { int i = i; }

Output:

examples/IllegalSelfRef.java:27: error: self-reference in initializer int i = i; ^ 1 error

IllegalStartOfExpr.java

Copyright, Info

class IllegalStartOfExpr { int i = =3; }

Output:

examples/IllegalStartOfExpr.java:27: error: illegal start of expression int i = =3; ^ 1 error

IllegalStartOfStmt.java

Copyright, Info

class IllegalStartOfStmt { void m() { if (true) } } }

Output:

examples/IllegalStartOfStmt.java:29: error: illegal start of statement if (true) } ^ examples/IllegalStartOfStmt.java:31: error: class, interface, or enum expected } ^ 2 errors

IllegalStaticIntfMethCall.java

Copyright, Info

class IllegalStaticIntfMethCall { interface A { static void m() { } } void test(A a) { a.m(); } }

Output:

examples/IllegalStaticIntfMethCall.java:32: error: illegal static interface method call a.m(); ^ the receiver expression should be replaced with the type qualifier 'A' 1 error

IllegalUnderscore.java

Copyright, Info

class X { int i = 1_; }

Output:

examples/IllegalUnderscore.java:27: error: illegal underscore int i = 1_; ^ 1 error

IllegalUnicodeEscape.java

Copyright, Info

class IllegalUnicodeEscape { int i = \u; }

Output:

examples/IllegalUnicodeEscape.java:27: error: illegal unicode escape int i = \u; ^ 1 error

ImportRequiresCanonical

ImportRequiresCanonical.java
Copyright, Info

import p.ExtendsBase.NestedInBase; class ImportRequiredCanonical { }

p/Base.java
Copyright

package p; public class Base { public static class NestedInBase { } }

p/ExtendsBase.java
Copyright

package p; public class ExtendsBase extends Base { }

Output:

examples/ImportRequiresCanonical/ImportRequiresCanonical.java:26: error: import requires canonical name for NestedInBase import p.ExtendsBase.NestedInBase; ^ 1 error

ImproperSVUID.java

Copyright, Info

import java.io.Serializable; class ImproperSVUID implements Serializable { int serialVersionUID; }

Output:

examples/ImproperSVUID.java:30: warning: [serial] serialVersionUID must be declared static final in class ImproperSVUID int serialVersionUID; ^ 1 warning

ImproperTypeInnerRawParam.java

Copyright, Info

class ImproperTypeInnerRawParam { class Outer<S> { class Inner<T> {} } void m() { Object o = (Outer.Inner<?>)null; } }

Output:

examples/ImproperTypeInnerRawParam.java:32: error: improperly formed type, type arguments given on a raw type Object o = (Outer.Inner<?>)null; ^ 1 error

ImproperTypeParamMissing.java

Copyright, Info

class ImproperTypeParamMissing { class Outer<S> { class Inner<T> {} } void m() { Object o = (Outer<?>.Inner)null; } }

Output:

examples/ImproperTypeParamMissing.java:32: error: improperly formed type, some parameters are missing Object o = (Outer<?>.Inner)null; ^ 1 error

InaccessibleVarargsType

InaccessibleVarargsType.java
Copyright, Info

import p1.B; class InaccessibleVarargsType { { new B().foo(new B(), new B()); } }

p1/A.java
Copyright

package p1; class A { A() { } }

p1/B.java
Copyright

package p1; public class B extends A { public B() {} public void foo(A... args) { } }

Output:

examples/InaccessibleVarargsType/InaccessibleVarargsType.java:30: error: method foo in class B cannot be applied to given types; { new B().foo(new B(), new B()); } ^ required: A[] found: B,B reason: formal varargs element type A is not accessible from class InaccessibleVarargsType 1 error

InapplicableSymbols.java

Copyright, Info

class ExplicitParamsDoNotConformToBounds { void m(int i1) {} void m(int i1, int i2) {} { this.m(); } }

Output:

examples/InapplicableSymbols.java:31: error: no suitable method found for m(no arguments) { this.m(); } ^ method ExplicitParamsDoNotConformToBounds.m(int) is not applicable (actual and formal argument lists differ in length) method ExplicitParamsDoNotConformToBounds.m(int,int) is not applicable (actual and formal argument lists differ in length) 1 error

IncomparableTypes.java

Copyright, Info

class X { boolean b = (this == 1); }

Output:

examples/IncomparableTypes.java:27: error: incomparable types: X and int boolean b = (this == 1); ^ 1 error

IncompatibleAbstracts.java

Copyright, Info

class IncompatibleAbstracts { interface SAM { void m(String s); void m(Integer i); } SAM s = x-> { }; }

Output:

examples/IncompatibleAbstracts.java:35: error: incompatible types: SAM is not a functional interface SAM s = x-> { }; ^ multiple non-overriding abstract methods found in interface SAM 1 error

IncompatibleArgTypesInLambda.java

Copyright, Info

class IncompatibleArgTypesInLambda { interface SAM { void m(Integer x); } SAM s = (String x)-> {}; }

Output:

examples/IncompatibleArgTypesInLambda.java:32: error: incompatible types: incompatible parameter types in lambda expression SAM s = (String x)-> {}; ^ 1 error

IncompatibleArgTypesInMethodRef.java

Copyright, Info

class IncompatibleArgTypesInMethodRef { interface SAM<X> { void m(X x); } void g(String s, Integer i) { } <Z> void m(SAM<Z> s) { } void test() { m(this::g); } }

Output:

examples/IncompatibleArgTypesInMethodRef.java:38: error: method m in class IncompatibleArgTypesInMethodRef cannot be applied to given types; m(this::g); ^ required: SAM<Z> found: this::g reason: cannot infer type-variable(s) Z (argument mismatch; incompatible parameter types in method reference) where Z is a type-variable: Z extends Object declared in method <Z>m(SAM<Z>) 1 error

IncompatibleDescsInFunctionalIntf.java

Copyright, Info

class IncompatibleDescsInFunctionalIntf { interface A { Integer m(String i) throws Exception; } interface B { String m(String i); } interface SAM extends A,B { } SAM s = x-> { }; }

Output:

examples/IncompatibleDescsInFunctionalIntf.java:39: error: types B and A are incompatible; both define m(java.lang.String), but with unrelated return types interface SAM extends A,B { } ^ examples/IncompatibleDescsInFunctionalIntf.java:41: error: incompatible types: incompatible function descriptors found in interface SAM SAM s = x-> { }; ^ descriptor: String m(String) descriptor: Integer m(String) throws Exception 2 errors

IncompatibleEqUpperBounds.java

Copyright, Info

import java.util.List; class IncompatibleEqUpperBounds { <S, T extends List<S>> void m(List<? super S> s1, T s2) { } void test(List<Integer> li, List<String> ls) { m(li, ls); } }

Output:

examples/IncompatibleEqUpperBounds.java:33: error: method m in class IncompatibleEqUpperBounds cannot be applied to given types; m(li, ls); ^ required: List<? super S>,T found: List<Integer>,List<String> reason: inference variable S has incompatible bounds equality constraints: String upper bounds: Integer,Object where S,T are type-variables: S extends Object declared in method <S,T>m(List<? super S>,T) T extends List<S> declared in method <S,T>m(List<? super S>,T) 1 error

IncompatibleRetTypeInLambda.java

Copyright, Info

class IncompatibleRetTypeInLambda { interface SAM { Integer m(); } SAM s = ()-> ""; }

Output:

examples/IncompatibleRetTypeInLambda.java:33: error: incompatible types: bad return type in lambda expression SAM s = ()-> ""; ^ String cannot be converted to Integer 1 error

IncompatibleRetTypeInMref.java

Copyright, Info

class IncompatibleRetTypeInMref { interface SAM { Integer m(); } static String f() { } SAM s = IncompatibleRetTypeInMref::f; }

Output:

examples/IncompatibleRetTypeInMref.java:35: error: incompatible types: bad return type in method reference SAM s = IncompatibleRetTypeInMref::f; ^ String cannot be converted to Integer 1 error

IncompatibleThrownTypesInLambda.java

Copyright, Info

class IncompatibleThrownTypesInLambda { interface SAM { void m(); } SAM s = ()-> { throw new Exception(); }; }

Output:

examples/IncompatibleThrownTypesInLambda.java:31: error: incompatible thrown types Exception in lambda expression SAM s = ()-> { throw new Exception(); }; ^ 1 error

IncompatibleThrownTypesInMref.java

Copyright, Info

class IncompatibleThrownTypesInMref { interface SAM { void m(); } static void f() throws Exception { } SAM s = IncompatibleThrownTypesInMref::f; }

Output:

examples/IncompatibleThrownTypesInMref.java:33: error: incompatible thrown types Exception in method reference SAM s = IncompatibleThrownTypesInMref::f; ^ 1 error

IncompatibleTypes1.java

Copyright, Info

class IncompatibleTypes1<V> { <T> IncompatibleTypes1<Integer> m() { return null; } IncompatibleTypes1<? extends String> o = m(); }

Output:

examples/IncompatibleTypes1.java:32: error: incompatible types: no instance(s) of type variable(s) T exist so that IncompatibleTypes1<Integer> conforms to IncompatibleTypes1<? extends String> IncompatibleTypes1<? extends String> o = m(); ^ where T is a type-variable: T extends Object declared in method <T>m() 1 error

IncompatibleTypesInConditional.java

Copyright, Info

class IncompatibleTypesInConditional { interface A { } interface B { } B b = true ? (A)null : (B)null; }

Output:

examples/IncompatibleTypesInConditional.java:33: error: incompatible types: bad type in conditional expression B b = true ? (A)null : (B)null; ^ A cannot be converted to B 1 error

IncompatibleUpperBounds.java

Copyright, Info

import java.util.List; class IncompatibleUpperBounds { <S> void m(List<? super S> s1, List<? super S> s2) { } void m(Object o) {} void test(List<Integer> li, List<String> ls) { m(li, ls); } }

Output:

examples/IncompatibleUpperBounds.java:36: error: method m in class IncompatibleUpperBounds cannot be applied to given types; m(li, ls); ^ required: List<? super S>,List<? super S> found: List<Integer>,List<String> reason: inference variable S has incompatible upper bounds String,Integer,Object where S is a type-variable: S extends Object declared in method <S>m(List<? super S>,List<? super S>) Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 1 error

InconvertibleTypes.java

Copyright, Info

class InconvertibleTypes { class Outer<S> { class Inner<T> {} } void m(Outer<Integer>.Inner<Long> p) { Object o = (Outer<? super Number>.Inner<Long>)p; } }

Output:

examples/InconvertibleTypes.java:33: error: incompatible types: InconvertibleTypes.Outer<Integer>.Inner<Long> cannot be converted to InconvertibleTypes.Outer<? super Number>.Inner<Long> Object o = (Outer<? super Number>.Inner<Long>)p; ^ 1 error

IncorrectConstructorReceiverName.java

Copyright, Info

class IncorrectConstructorReceiverName { class Inner { Inner(IncorrectConstructorReceiverName this) { } } }

Output:

examples/IncorrectConstructorReceiverName.java:28: error: the receiver name does not match the enclosing outer class type Inner(IncorrectConstructorReceiverName this) { } ^ required: IncorrectConstructorReceiverName found: IncorrectConstructorReceiverName.Inner 1 error

IncorrectConstructorReceiverType.java

Copyright, Info

class IncorrectConstructorReceiverType { class Inner { Inner(Object IncorrectConstructorReceiverType.this) { } } }

Output:

examples/IncorrectConstructorReceiverType.java:28: error: the receiver type does not match the enclosing outer class type Inner(Object IncorrectConstructorReceiverType.this) { } ^ required: IncorrectConstructorReceiverType found: Object 1 error

IncorrectReceiverName.java

Copyright, Info

class IncorrectReceiverName { class Inner { void m(Inner IncorrectReceiverName.this) { } } }

Output:

examples/IncorrectReceiverName.java:28: error: the receiver name does not match the enclosing class type void m(Inner IncorrectReceiverName.this) { } ^ required: IncorrectReceiverName.Inner found: IncorrectReceiverName 1 error

IncorrectReceiverType.java

Copyright, Info

class IncorrectReceiverType { void m(Object this) {} }

Output:

examples/IncorrectReceiverType.java:27: error: the receiver type does not match the enclosing class type void m(Object this) {} ^ required: IncorrectReceiverType found: Object 1 error

InexactVarargsCall.java

Copyright, Info

class C { void m(Object... args) { } } class InexactVarargsCall { void m() { C c = new C(); c.m(null); } }

Output:

examples/InexactVarargsCall.java:33: warning: non-varargs call of varargs method with inexact argument type for last parameter; c.m(null); ^ cast to Object for a varargs call cast to Object[] for a non-varargs call and to suppress this warning 1 warning

InferArgsLengthMismatch.java

Copyright, Info

class InferArgsLengthMismatch { <X extends Number> void m(X x1, X x2) {} { this.m(1); } }

Output:

examples/InferArgsLengthMismatch.java:29: error: method m in class InferArgsLengthMismatch cannot be applied to given types; { this.m(1); } ^ required: X,X found: int reason: cannot infer type-variable(s) X (actual and formal argument lists differ in length) where X is a type-variable: X extends Number declared in method <X>m(X,X) 1 error

InferNoConformingAssignment.java

Copyright, Info

import java.util.*; class InferNoConformingAssignment { <X extends Number> List<X> m(String s) { return null; } { this.m(1); } }

Output:

examples/InferNoConformingAssignment.java:32: error: method m in class InferNoConformingAssignment cannot be applied to given types; { this.m(1); } ^ required: String found: int reason: cannot infer type-variable(s) X (argument mismatch; int cannot be converted to String) where X is a type-variable: X extends Number declared in method <X>m(String) 1 error

InferVarargsArgumentMismatch.java

Copyright, Info

class InferVarargsArgumentMismatch { <X> void m(X x1, String... xs) {} { this.m("", 1); } }

Output:

examples/InferVarargsArgumentMismatch.java:30: error: method m in class InferVarargsArgumentMismatch cannot be applied to given types; { this.m("", 1); } ^ required: X,String[] found: String,int reason: cannot infer type-variable(s) X (varargs mismatch; int cannot be converted to String) where X is a type-variable: X extends Object declared in method <X>m(X,String...) 1 error

InferredDoNotConformToEq.java

Copyright, Info

import java.util.*; class InferredDoNotConformToEq { <X> void m(List<X> lx1, List<X> lx2) {} { this.m(Arrays.asList(""), Arrays.asList(1)); } }

Output:

examples/InferredDoNotConformToEq.java:32: error: method m in class InferredDoNotConformToEq cannot be applied to given types; { this.m(Arrays.asList(""), Arrays.asList(1)); } ^ required: List<X>,List<X> found: List<String>,List<Integer> reason: inferred type does not conform to equality constraint(s) inferred: Integer equality constraints(s): Integer,String where X is a type-variable: X extends Object declared in method <X>m(List<X>,List<X>) 1 error

InferredDoNotConformToUpper.java

Copyright, Info

import java.util.*; class InferredDoNotConformToUpper { <X> void m(X x, List<? super X> lx) {} { this.m("", Arrays.asList(1)); } }

Output:

examples/InferredDoNotConformToUpper.java:32: error: method m in class InferredDoNotConformToUpper cannot be applied to given types; { this.m("", Arrays.asList(1)); } ^ required: X,List<? super X> found: String,List<Integer> reason: inferred type does not conform to upper bound(s) inferred: String upper bound(s): Integer,Object where X is a type-variable: X extends Object declared in method <X>m(X,List<? super X>) 1 error

InheritFromFinal.java

Copyright, Info

final class Base { } class InheritFromFinal extends Base { }

Output:

examples/InheritFromFinal.java:28: error: cannot inherit from final Base class InheritFromFinal extends Base { } ^ 1 error

InitializerMustComplete.java

Copyright, Info

class InitializerMustComplete { { throw new IllegalStateException(); } }

Output:

examples/InitializerMustComplete.java:27: error: initializer must be able to complete normally { ^ 1 error

InnerClassCantHaveStatic.java

Copyright, Info

class InnerClassCantHaveStatic { class Inner { static int i; } }

Output:

examples/InnerClassCantHaveStatic.java:28: error: Illegal static declaration in inner class InnerClassCantHaveStatic.Inner static int i; ^ modifier 'static' is only allowed in constant variable declarations 1 error

IntNumberTooLarge.java

Copyright, Info

class IntNumberTooLarge { int i = 12345678901234567890; }

Output:

examples/IntNumberTooLarge.java:27: error: integer number too large: 12345678901234567890 int i = 12345678901234567890; ^ 1 error

InterfaceExpected.java

Copyright, Info

class InterfaceExpected implements String { }

Output:

examples/InterfaceExpected.java:26: error: interface expected here class InterfaceExpected implements String { } ^ 1 error

InterfaceNotAllowed.java

Copyright, Info

class InterfaceNotAllowed { void m() { interface I { } } }

Output:

examples/InterfaceNotAllowed.java:28: error: interface not allowed here interface I { } ^ 1 error

IntersectionTypesInCastNotSupported.java

Copyright, Info

interface IntersectionTypesInCastNotSupported { Object o = (A & B)null; }

Output:

examples/IntersectionTypesInCastNotSupported.java:28: error: intersection types in cast are not supported in -source 1.7 Object o = (A & B)null; ^ (use -source 8 or higher to enable default methods) 1 error

IntfAnnotationCantHaveTypeParams.java

Copyright, Info

@interface X<T> { }

Output:

examples/IntfAnnotationCantHaveTypeParams.java:26: error: @interface may not have type parameters @interface X<T> { } ^ 1 error

IntfAnnotationMemberClash.java

Copyright, Info

@interface X { String toString(); }

Output:

examples/IntfAnnotationMemberClash.java:27: error: @interface member clashes with method 'toString()' in Annotation String toString(); ^ 1 error

IntfAnnotationsCantHaveParams.java

Copyright, Info

@interface X { String value(int i); }

Output:

examples/IntfAnnotationsCantHaveParams.java:27: error: @interface members may not have parameters String value(int i); ^ 1 error

IntfAnnotationsCantHaveTypeParams.java

Copyright, Info

@interface X { <T> String value(); }

Output:

examples/IntfAnnotationsCantHaveTypeParams.java:27: error: @interface members may not have type parameters <T> String value(); ^ 1 error

IntfMethodCantHaveBody.java

Copyright, Info

interface IntfMethodCantHaveBody { void m() { } }

Output:

examples/IntfMethodCantHaveBody.java:27: error: interface abstract methods cannot have body void m() { } ^ 1 error

InvalidAnnoMemberType.java

Copyright, Info

@interface InvalidAnnoMemberType { Object value(); }

Output:

examples/InvalidAnnoMemberType.java:27: error: invalid type for annotation member Object value(); ^ 1 error

InvalidBinaryNumber.java

Copyright, Info

class InvalidBinaryNumber { int i = 0b201000010; }

Output:

examples/InvalidBinaryNumber.java:30: error: binary numbers must contain at least one binary digit int i = 0b201000010; ^ examples/InvalidBinaryNumber.java:30: error: illegal start of type int i = 0b201000010; ^ examples/InvalidBinaryNumber.java:30: error: <identifier> expected int i = 0b201000010; ^ examples/InvalidBinaryNumber.java:30: error: ';' expected int i = 0b201000010; ^ examples/InvalidBinaryNumber.java:31: error: reached end of file while parsing } ^ 5 errors

InvalidDuplicateAnnotation.java

Copyright, Info

// We need an almost valid containing annotation. The easiest way to get // one close enough to valid is by forgetting a default. import java.lang.annotation.*; @Repeatable(Annos.class) @interface Anno { } @interface Annos { Anno[] value(); String foo(); } @Anno @Anno class InvalidDuplicateAnnotation { }

Output:

examples/InvalidDuplicateAnnotation.java:37: error: annotation Anno cannot be repeated @Anno ^ It does not define a valid containing annotation. examples/InvalidDuplicateAnnotation.java:32: error: containing annotation Annos does not have a default value for element foo() @Repeatable(Annos.class) ^ 2 errors

InvalidGenericLambdaTarget.java

Copyright, Info

class InvalidGenericLambdaTarget { interface SAM { <Z> void m(); } SAM s = x-> { }; }

Output:

examples/InvalidGenericLambdaTarget.java:33: error: incompatible types: invalid functional descriptor for lambda expression SAM s = x-> { }; ^ method <Z>()void in interface SAM is generic where Z is a type-variable: Z extends Object declared in method <Z>m() 1 error

InvalidHexNumber.java

Copyright, Info

class InvalidHexNumber { int i = 0xz1357abc; }

Output:

examples/InvalidHexNumber.java:28: error: hexadecimal numbers must contain at least one hexadecimal digit int i = 0xz1357abc; ^ examples/InvalidHexNumber.java:28: error: <identifier> expected int i = 0xz1357abc; ^ 2 errors

InvalidInstanceof.java

Copyright, Info

import java.util.*; class IllegalInstanceof { List o; boolean b = (o instanceof List<String>); }

Output:

examples/InvalidInstanceof.java:30: error: illegal generic type for instanceof boolean b = (o instanceof List<String>); ^ 1 error

InvalidMethodDecl.java

Copyright, Info

class InvalidMethodDecl { m() { } }

Output:

examples/InvalidMethodDecl.java:27: error: invalid method declaration; return type required m() { } ^ 1 error

KindnameClass.java

Copyright, Info

class KindnameClass { NotFound x; }

Output:

examples/KindnameClass.java:32: error: cannot find symbol NotFound x; ^ symbol: class NotFound location: class KindnameClass 1 error

KindnameConstructor.java

Copyright, Info

class KindnameConstructor { KindnameConstructor(Integer x) {} void m() { new KindnameConstructor(""){}; } }

Output:

examples/KindnameConstructor.java:39: error: constructor KindnameConstructor in class KindnameConstructor cannot be applied to given types; new KindnameConstructor(""){}; ^ required: Integer found: String reason: argument mismatch; String cannot be converted to Integer 1 error

KindnameInstanceInit.java

Copyright, Info

class KindnameInstanceInit { { int i; int i; } }

Output:

examples/KindnameInstanceInit.java:35: error: variable i is already defined in instance initializer of class KindnameInstanceInit int i; ^ 1 error

KindnameMethod.java

Copyright, Info

class KindnameMethod { Object o = not_found(); }

Output:

examples/KindnameMethod.java:33: error: cannot find symbol Object o = not_found(); ^ symbol: method not_found() location: class KindnameMethod 1 error

KindnameStaticInit.java

Copyright, Info

class KindnameStaticInit { static { int i; int i; } }

Output:

examples/KindnameStaticInit.java:35: error: variable i is already defined in static initializer of class KindnameStaticInit int i; ^ 1 error

KindnameVariable.java

Copyright, Info

class KindnameVariable { Object o = not_found; }

Output:

examples/KindnameVariable.java:33: error: cannot find symbol Object o = not_found; ^ symbol: variable not_found location: class KindnameVariable 1 error

LabelInUse.java

Copyright, Info

class LabelInUse { void m(String... args) { label: for (String a1: args) { label: for (String a2: args) { System.out.println(a1 + " " + a2); } } } }

Output:

examples/LabelInUse.java:30: error: label label already in use label: ^ 1 error

LambdaNotSupported.java

Copyright, Info

class LambdaNotSupported { S s = ()->{}; }

Output:

examples/LambdaNotSupported.java:28: error: lambda expressions are not supported in -source 1.7 S s = ()->{}; ^ (use -source 8 or higher to enable lambda expressions) 1 error

LambdaStat.java

Copyright, Info

class LambdaStat { Runnable r = ()->{}; }

Output:

examples/LambdaStat.java:28: Note: Translating lambda expression Runnable r = ()->{}; ^ alternate metafactory = false synthetic method = lambda$0

LocalEnum.java

Copyright, Info

class LocalEnum { void m() { enum E { a, b, c}; } }

Output:

examples/LocalEnum.java:28: error: enum types must not be local enum E { a, b, c}; ^ 1 error

LocalVarNeedsFinal.java

Copyright, Info

class LocalVarNeedsFinal { Runnable m() { int i = 3; return new Runnable() { public void run() { System.out.println(i); } }; } }

Output:

examples/LocalVarNeedsFinal.java:32: error: local variable i is accessed from within inner class; needs to be declared final System.out.println(i); ^ 1 error

Location.java

Copyright, Info

class Location { { Object o = v; } }

Output:

examples/Location.java:28: error: cannot find symbol { Object o = v; } ^ symbol: variable v location: class Location 1 error

Location1.java

Copyright, Info

class Location1 { Object o = null; { Object o2 = o.v; } }

Output:

examples/Location1.java:29: error: cannot find symbol { Object o2 = o.v; } ^ symbol: variable v location: variable o of type Object 1 error

LongSVUID.java

Copyright, Info

import java.io.Serializable; class LongSVUID implements Serializable { private static final int serialVersionUID = 0; }

Output:

examples/LongSVUID.java:30: warning: [serial] serialVersionUID must be of type long in class LongSVUID private static final int serialVersionUID = 0; ^ 1 warning

MalformedFpLit.java

Copyright, Info

class MalformedFpLit { float f = 0e*; }

Output:

examples/MalformedFpLit.java:28: error: malformed floating point literal float f = 0e*; ^ examples/MalformedFpLit.java:28: error: illegal start of expression float f = 0e*; ^ 2 errors

MalformedHTML.java

Copyright, Info

/** <b */ class MalformedHTML { }

Output:

Note: malformed HTML

MalformedSupported

MalformedSupported.java
Copyright, Info

class MalformedSupported { }

processors/AnnoProc.java
Copyright

import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; @SupportedAnnotationTypes("java.lang.*,javx.lang.*") public class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { return true; } public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } }

Output:

warning: Malformed string 'java.lang.*,javx.lang.*' for a supported annotation type returned by processor 'AnnoProc' 1 warning

MethodDoesNotOverride.java

Copyright, Info

class X { @Override void m() { } }

Output:

examples/MethodDoesNotOverride.java:27: error: method does not override or implement a method from a supertype @Override ^ 1 error

MethodReferencesNotSupported.java

Copyright, Info

class MethodReferencesNotSupported { S s = A::foo; }

Output:

examples/MethodReferencesNotSupported.java:28: error: method references are not supported in -source 1.7 S s = A::foo; ^ (use -source 8 or higher to enable method references) 1 error

MightBeAssignedInLoop.java

Copyright, Info

class X { void m(int n) { final int i; for (int c = 0; c < n; c++) { i = 3; } } }

Output:

examples/MightBeAssignedInLoop.java:30: error: variable i might be assigned in loop i = 3; ^ 1 error

MissingDeprecatedAnnotation.java

Copyright, Info

/** @deprecated */ class MissingDeprecatedAnnotation { }

Output:

examples/MissingDeprecatedAnnotation.java:28: warning: [dep-ann] deprecated item is not annotated with @Deprecated class MissingDeprecatedAnnotation { ^ 1 warning

MissingMethodBody.java

Copyright, Info

class MissingMethodBody { void m(); }

Output:

examples/MissingMethodBody.java:27: error: missing method body, or declare abstract void m(); ^ 1 error

MissingReturnStatement.java

Copyright, Info

class MissingReturnStatement { int m() { } }

Output:

examples/MissingReturnStatement.java:28: error: missing return statement } ^ 1 error

MissingReturnValue.java

Copyright, Info

class MissingReturnValue { int m() { return; } }

Output:

examples/MissingReturnValue.java:29: error: incompatible types: missing return value return; ^ 1 error

MissingReturnValueFragment.java

Copyright, Info

class MissingReturnValueFragment { interface SAM { String m(); } void test() { SAM s = ()->{}; } }

Output:

examples/MissingReturnValueFragment.java:34: error: incompatible types: bad return type in lambda expression SAM s = ()->{}; ^ missing return value 1 error

MissingSVUID.java

Copyright, Info

import java.io.Serializable; class MissingSVUID implements Serializable { }

Output:

examples/MissingSVUID.java:29: warning: [serial] serializable class MissingSVUID has no definition of serialVersionUID class MissingSVUID implements Serializable { ^ 1 warning

MissingSemicolon.java

Copyright, Info

/** &lt */ class MissingSemicolon { }

Output:

Note: semicolon missing

ModifierNotAllowed.java

Copyright, Info

synchronized interface ModifierNotAllowed { }

Output:

examples/ModifierNotAllowed.java:26: error: modifier synchronized not allowed here synchronized interface ModifierNotAllowed { } ^ 1 error

MrefStat.java

Copyright, Info

class MrefStat { Runnable r = MrefStat::m; static void m() { } }

Output:

examples/MrefStat.java:28: Note: Translating method reference Runnable r = MrefStat::m; ^ alternate metafactory = false

MrefStat1.java

Copyright, Info

class MrefStat1 { void m() { } static class Sub extends MrefStat1 { Runnable r = super::m; } }

Output:

examples/MrefStat1.java:32: Note: Translating method reference Runnable r = super::m; ^ alternate metafactory = false bridge method = lambda$0$bridge

MulticatchCantBeAssigned.java

Copyright, Info

class MulticatchCantBeAssigned{ void e1() throws NullPointerException { } void e2() throws IllegalArgumentException { } void m() { try { e1(); e2(); } catch (final NullPointerException | IllegalArgumentException e) { e = new RuntimeException(); } } }

Output:

examples/MulticatchCantBeAssigned.java:35: error: multi-catch parameter e may not be assigned e = new RuntimeException(); ^ 1 error

MulticatchNotSupported.java

Copyright, Info

class MulticatchNotSupported { class E1 extends Exception { } class E2 extends Exception { } void e1() throws E1 { } void e2() throws E2 { } void m() { try { e1(); e2(); } catch (final E1 | E2 e) { e.printStackTrace(); } } }

Output:

examples/MulticatchNotSupported.java:38: error: multi-catch statement is not supported in -source 1.6 } catch (final E1 | E2 e) { ^ (use -source 7 or higher to enable multi-catch statement) 1 error

MulticatchTypesMustBeDisjoint.java

Copyright, Info

class MulticatchTypesMustBeDisjoint { class E1 extends Exception { } class E2 extends E1 { } void e1() throws E1 { } void e2() throws E2 { } void m() { try { e1(); e2(); } catch (E1 | E2 e) { } } }

Output:

examples/MulticatchTypesMustBeDisjoint.java:37: error: Alternatives in a multi-catch statement cannot be related by subclassing } catch (E1 | E2 e) { } ^ Alternative MulticatchTypesMustBeDisjoint.E2 is a subclass of alternative MulticatchTypesMustBeDisjoint.E1 1 error

NameClashSameErasure.java

Copyright, Info

import java.util.*; class NameClassSameErasure { void m(List<Integer> list) { } void m(List<String> list) { } }

Output:

examples/NameClashSameErasure.java:30: error: name clash: m(List<String>) and m(List<Integer>) have the same erasure void m(List<String> list) { } ^ 1 error

NameClashSameErasureNoHide.java

Copyright, Info

public class NameClashSameErasureNoHide<X> { static class A { static void m(NameClashSameErasureNoHide<String> l) {} } static class B extends A { static void m(NameClashSameErasureNoHide<Integer> l) {} } }

Output:

examples/NameClashSameErasureNoHide.java:32: error: name clash: m(NameClashSameErasureNoHide<Integer>) in B and m(NameClashSameErasureNoHide<String>) in A have the same erasure, yet neither hides the other static void m(NameClashSameErasureNoHide<Integer> l) {} ^ 1 error

NameClashSameErasureNoOverride.java

Copyright, Info

public class NameClashSameErasureNoOverride<X> { static class A { void m(NameClashSameErasureNoOverride<String> l) {} } static class B extends A { void m(NameClashSameErasureNoOverride<Integer> l) {} } }

Output:

examples/NameClashSameErasureNoOverride.java:32: error: name clash: m(NameClashSameErasureNoOverride<Integer>) in B and m(NameClashSameErasureNoOverride<String>) in A have the same erasure, yet neither overrides the other void m(NameClashSameErasureNoOverride<Integer> l) {} ^ 1 error

NameClashSameErasureNoOverride1.java

Copyright, Info

public class NameClashSameErasureNoOverride1 { interface I<X> { void m(X l); } class A { void m(Object l) {} } class B extends A implements I<Integer> { public void m(Integer l) {} } }

Output:

examples/NameClashSameErasureNoOverride1.java:37: error: name clash: m(Integer) in NameClashSameErasureNoOverride1.B overrides a method whose erasure is the same as another method, yet neither overrides the other public void m(Integer l) {} ^ first method: m(Object) in NameClashSameErasureNoOverride1.A second method: m(X) in I where X is a type-variable: X extends Object declared in interface I 1 error

NativeMethodCantHaveBody.java

Copyright, Info

abstract class NativeMethodCantHaveBody { native void m() { } }

Output:

examples/NativeMethodCantHaveBody.java:27: error: native methods cannot have a body native void m() { } ^ 1 error

NeitherConditionalSubtype.java

Copyright, Info

class X { Object m(boolean b) { return (b ? 3 : b); } }

Output:

examples/NeitherConditionalSubtype.java:29: error: incompatible types for ?: neither is a subtype of the other return (b ? 3 : b); ^ second operand: int third operand : boolean 1 error

NewNotAllowedInAnno.java

Copyright, Info

@interface Anno { int[] value(); } @Anno(new int[] { 1, 2, 3 }) class X { }

Output:

examples/NewNotAllowedInAnno.java:30: error: 'new' not allowed in an annotation @Anno(new int[] { 1, 2, 3 }) ^ 1 error

NoAbstracts.java

Copyright, Info

class NoAbstracts { interface SAM { } SAM s = x-> { }; }

Output:

examples/NoAbstracts.java:32: error: incompatible types: SAM is not a functional interface SAM s = x-> { }; ^ no abstract method found in interface SAM 1 error

NoAnnotationsOnDotClass.java

Copyright, Info

class NoAnnotationsOnDotClass { @Target(ElementType.TYPE_USE) @interface A {} Object o = @A Object.class; }

Output:

examples/NoAnnotationsOnDotClass.java:30: error: no annotations are allowed in the type of a class literal Object o = @A Object.class; ^ 1 error

NoArgs.java

Copyright, Info

class X { void m1(int i) { } int x = m1(); }

Output:

examples/NoArgs.java:32: error: method m1 in class X cannot be applied to given types; int x = m1(); ^ required: int found: no arguments reason: actual and formal argument lists differ in length 1 error

NoContent.java

Copyright, Info

/** @see */ class NoContent { }

Output:

Note: no content

NoExplicitAnnoProcRequested.java

Copyright, Info

class NoExplicitAnnoProcRequested { }

Output:

error: Class names, 'UnknownClass', are only accepted if annotation processing is explicitly requested 1 error

NoInterfaceExpected.java

Copyright, Info

class NoInterfaceExpected extends Runnable { }

Output:

examples/NoInterfaceExpected.java:26: error: no interface expected here class NoInterfaceExpected extends Runnable { } ^ 1 error

NoInterfaceHere.java

Copyright, Info

interface I { } class InterfaceNotExpected extends I { }

Output:

examples/NoInterfaceHere.java:28: error: no interface expected here class InterfaceNotExpected extends I { } ^ 1 error

NoJavaLang.java

Copyright, Info

class NoJavaLang { }

Output:

Fatal Error: Unable to find package java.lang in classpath or bootclasspath

NoSuitableFunctionalIntfInst.java

Copyright, Info

class NoSuitableFunctionalIntfInst { interface SAM<X extends Number> { void m(X x); } SAM<?> ss = (String s)-> { }; }

Output:

examples/NoSuitableFunctionalIntfInst.java:33: error: incompatible types: cannot infer functional interface descriptor for SAM<?> SAM<?> ss = (String s)-> { }; ^ 1 error

NoSuperclass.java

Copyright, Info

package java.lang; class Object { public Object() { super(); } }

Output:

examples/NoSuperclass.java:30: error: Object has no superclass super(); ^ 1 error

NoTagName.java

Copyright, Info

/** @ */ class NoTagName { }

Output:

Note: no tag name after @

NonStaticCantBeRef.java

Copyright, Info

class NonStaticCantBeRef { int i; static int m() { return i; } }

Output:

examples/NonStaticCantBeRef.java:30: error: non-static variable i cannot be referenced from a static context return i; ^ 1 error

NonStaticCantBeRefFragment.java

Copyright, Info

class NonStaticCantBeRefFragment { interface SAM { void m(Integer u); } void f(Integer i) { } static void test() { SAM s = NonStaticCantBeRefFragment::f; } }

Output:

examples/NonStaticCantBeRefFragment.java:36: error: invalid method reference SAM s = NonStaticCantBeRefFragment::f; ^ non-static method f(Integer) cannot be referenced from a static context 1 error

NotAFunctionalIntf.java

Copyright, Info

class NotAFunctionalIntf { abstract class SAM { abstract <Z> void m(); } SAM s = x-> { }; }

Output:

examples/NotAFunctionalIntf.java:33: error: incompatible types: NotAFunctionalIntf.SAM is not a functional interface SAM s = x-> { }; ^ 1 error

NotAStatement.java

Copyright, Info

class NotAStatement { void m() { x + 1; } }

Output:

examples/NotAStatement.java:28: error: not a statement x + 1; ^ 1 error

NotAllowedClass.java

Copyright, Info

class NotAllowedClass { void t1() { if (true) class X {} } }

Output:

examples/NotAllowedClass.java:29: error: class, interface or enum declaration not allowed here class X {} ^ 1 error

NotAllowedVariable.java

Copyright, Info

class NotAllowedVariable { void t1() { if (true) int x = 0; } }

Output:

examples/NotAllowedVariable.java:29: error: variable declaration not allowed here int x = 0; ^ 1 error

NotAnInterfaceComponent.java

Copyright, Info

class NotAnInterfaceComponent { Object o = (Object & Runnable) ()-> { }; }

Output:

examples/NotAnInterfaceComponent.java:29: error: incompatible types: bad intersection type target for lambda or method reference Object o = (Object & Runnable) ()-> { }; ^ component type Object is not an interface 1 error

NotApplicableMethodFound.java

Copyright, Info

class NotApplicableMethodFound { void m(int i) {} { m(""); } }

Output:

examples/NotApplicableMethodFound.java:35: Note: erroneous resolution for method m in type NotApplicableMethodFound { m(""); } ^ phase: BASIC with actuals: String with type-args: no arguments candidates: #0 not applicable method found: m(int) (argument mismatch; String cannot be converted to int) examples/NotApplicableMethodFound.java:35: Note: erroneous resolution for method m in type NotApplicableMethodFound { m(""); } ^ phase: BOX with actuals: String with type-args: no arguments candidates: #0 not applicable method found: m(int) (argument mismatch; String cannot be converted to int) examples/NotApplicableMethodFound.java:35: Note: erroneous resolution for method m in type NotApplicableMethodFound { m(""); } ^ phase: VARARITY with actuals: String with type-args: no arguments candidates: examples/NotApplicableMethodFound.java:35: error: incompatible types: String cannot be converted to int { m(""); } ^ Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 1 error

NotDefAccessClassIntfCantAccess

NotDefAccessClassIntfCantAccess.java
Copyright, Info

import p.C; class X { int m() { C c = new C(); return c.array.length; // array is public, but the type of the array is not } }

p/C.java
Copyright

package p; public class C { class Nested { } public Nested[] array; }

Output:

examples/NotDefAccessClassIntfCantAccess/NotDefAccessClassIntfCantAccess.java:31: error: length in Array is defined in an inaccessible class or interface return c.array.length; // array is public, but the type of the array is not ^ 1 error

NotDefAccessClassIntfCantAccessFragment.java

Copyright, Info

class NotDefAccessClassIntfCantAccessFragment { private class Private { void m() { } } Private getPrivate() { return new Private(); } } class NotDefAccessClassIntfCantAccessFragmentTest { interface SAM { void m(); } static void test() { SAM s = new NotDefAccessClassIntfCantAccessFragment().getPrivate()::m; } }

Output:

examples/NotDefAccessClassIntfCantAccessFragment.java:44: error: incompatible types: invalid method reference SAM s = new NotDefAccessClassIntfCantAccessFragment().getPrivate()::m; ^ m() in NotDefAccessClassIntfCantAccessFragment.Private is defined in an inaccessible class or interface 1 error

NotDefPublicCantAccess

NotDefPublicCantAccess.java
Copyright, Info

class X { Object o = new p.C(); }

p/C.java
Copyright

package p; class C { }

Output:

examples/NotDefPublicCantAccess/NotDefPublicCantAccess.java:27: error: C is not public in p; cannot be accessed from outside package Object o = new p.C(); ^ 1 error

NotDefPublicCantAccessFragment

NotDefPublicCantAccessFragment.java
Copyright, Info

class NotDefPublicCantAccessFragment { interface SAM { void m(); } void test (p.C c) { SAM s = c::m; } }

p/C.java
Copyright

package p; public class C { void m() { } }

Output:

examples/NotDefPublicCantAccessFragment/NotDefPublicCantAccessFragment.java:34: error: incompatible types: invalid method reference SAM s = c::m; ^ m() is not public in C; cannot be accessed from outside package 1 error

NotEnclClass.java

Copyright, Info

class NotEnclClass { Object o = Object.this; }

Output:

examples/NotEnclClass.java:27: error: not an enclosing class: Object Object o = Object.this; ^ 1 error

NotInProfile.java

Copyright, Info

class NotInProfile { Class<?> c = java.awt.Frame.class; }

Output:

examples/NotInProfile.java:28: error: Frame is not available in profile 'compact1' Class<?> c = java.awt.Frame.class; ^ 1 error

NotLoopLabel.java

Copyright, Info

class LabelInUse { void m() { label: { int[] values = { 1, 2, 3 }; for (int v: values) { if (v == 2) continue label; System.err.println(v); } } } }

Output:

examples/NotLoopLabel.java:32: error: not a loop label: label continue label; ^ 1 error

NotWithinBounds.java

Copyright, Info

class NotWithinBounds { static class Foo<X extends Number> { } Foo<String> f1 = null; }

Output:

examples/NotWithinBounds.java:30: error: type argument String is not within bounds of type-variable X Foo<String> f1 = null; ^ where X is a type-variable: X extends Number declared in class Foo 1 error

Note.java

Copyright, Info

import java.util.*; class Note { List<String> list = new ArrayList(); }

Output:

Note: examples/Note.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.

NoteProcMessager

NoteProcMessager.java
Copyright, Info

class NoteProcMessager { }

processors/AnnoProc.java
Copyright

import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; import javax.tools.*; @SupportedAnnotationTypes("*") public class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { if (renv.processingOver()) { Messager m = processingEnv.getMessager(); m.printMessage(Diagnostic.Kind.NOTE, "Note!"); } return true; } public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } }

Output:

Note: Note!

OperatorCantBeApplied.java

Copyright, Info

class OperatorCantBeApplied { String s = null; { s++; } }

Output:

examples/OperatorCantBeApplied.java:28: error: bad operand type String for unary operator '++' { s++; } ^ 1 error

OperatorCantBeApplied1.java

Copyright, Info

class OperatorCantBeApplied1 { String s = ("a" - "b"); }

Output:

examples/OperatorCantBeApplied1.java:27: error: bad operand types for binary operator '-' String s = ("a" - "b"); ^ first type: String second type: String 1 error

Orphaned.java

Copyright, Info

class Orphaned { void m() { case 3: System.out.println("3"); } }

Output:

examples/Orphaned.java:28: error: orphaned case case 3: ^ 1 error

OverriddenDefault.java

Copyright, Info

class OverriddenDefault { interface I { default void m() { } } interface J extends I { default void m() { } } interface K extends I {} static class C implements J, K { void foo() { K.super.m(); } } }

Output:

examples/OverriddenDefault.java:33: error: bad type qualifier K in default super call void foo() { K.super.m(); } ^ method m() is overridden in J 1 error

OverrideDoesntThrow.java

Copyright, Info

class Base { void m() { } } class OverrideDoesntThrow extends Base { void m() throws Exception { } }

Output:

examples/OverrideDoesntThrow.java:32: error: m() in OverrideDoesntThrow cannot override m() in Base void m() throws Exception { } ^ overridden method does not throw Exception 1 error

OverrideIncompatibleReturn.java

Copyright, Info

class Base { int m() { return 0; } } class OverrideIncompatibleReturn extends Base { String m() { return null; } }

Output:

examples/OverrideIncompatibleReturn.java:34: error: m() in OverrideIncompatibleReturn cannot override m() in Base String m() { ^ return type String is not compatible with int 1 error

OverrideMeth.java

Copyright, Info

class Base { static void m() { } } class OverrideMeth extends Base { void m() { } }

Output:

examples/OverrideMeth.java:32: error: m() in OverrideMeth cannot override m() in Base void m() { } ^ overridden method is static 1 error

OverrideStatic.java

Copyright, Info

class Base { void m() { } } class OverrideStatic extends Base { static void m() { } }

Output:

examples/OverrideStatic.java:32: error: m() in OverrideStatic cannot override m() in Base static void m() { } ^ overriding method is static 1 error

OverrideUncheckedReturn.java

Copyright, Info

import java.util.*; class Base { List<String> m() { return null; } } class OverrideUncheckedReturn extends Base { List m() { return null; } }

Output:

examples/OverrideUncheckedReturn.java:35: warning: [unchecked] m() in OverrideUncheckedReturn overrides m() in Base List m() { return null; } ^ return type requires unchecked conversion from List to List<String> 1 warning

OverrideUncheckedThrown.java

Copyright, Info

class Base { <T extends Exception> void m() throws T { } } class OverrideUncheckedThrown extends Base { void m() throws Exception { } }

Output:

examples/OverrideUncheckedThrown.java:33: warning: [unchecked] m() in OverrideUncheckedThrown cannot override <T>m() in Base void m() throws Exception { } ^ overridden method does not throw Exception where T is a type-variable: T extends Exception declared in method <T>m() 1 warning

OverrideVarargsExtra.java

Copyright, Info

class Base { void m(Object... x) { } } class OverrideVarargsExtra extends Base { void m(Object[] x) { } }

Output:

examples/OverrideVarargsExtra.java:33: warning: m(Object[]) in OverrideVarargsExtra overrides m(Object...) in Base; overriding method is missing '...' void m(Object[] x) { } ^ 1 warning

OverrideVarargsMissing.java

Copyright, Info

class Base { void m(Object[] x) { } } class OverrideVarargsMissing extends Base { void m(Object... x) { } }

Output:

examples/OverrideVarargsMissing.java:33: warning: m(Object...) in OverrideVarargsMissing overrides m(Object[]) in Base; overridden method has no '...' void m(Object... x) { } ^ 1 warning

OverrideWeakerAccess.java

Copyright, Info

class OverrideWeakerAccess { String toString() { return "?"; } }

Output:

examples/OverrideWeakerAccess.java:28: error: toString() in OverrideWeakerAccess cannot override toString() in Object String toString() { return "?"; } ^ attempting to assign weaker access privileges; was public 1 error

PackageAnnos.java

Copyright, Info

@Deprecated package p; class PackageAnnos { }

Output:

examples/PackageAnnos.java:26: error: package annotations should be in file package-info.java @Deprecated ^ 1 error

PackageInfoAlreadySeen

package-info.java
Copyright, Info

package p;

p/package-info.java
Copyright

package p;

Output:

examples/PackageInfoAlreadySeen/package-info.java:26: warning: a package-info.java file has already been seen for package p package p; ^ 1 warning

PartialInstSig.java

Copyright, Info

class PartialInstSig { <X> X m() { return null; } { m(); } }

Output:

examples/PartialInstSig.java:33: Note: resolving method m in type PartialInstSig to candidate 0 { m(); } ^ phase: BASIC with actuals: no arguments with type-args: no arguments candidates: #0 applicable method found: <X>m() (partially instantiated to: ()Object) where X is a type-variable: X extends Object declared in method <X>m()

PathElementNotFound.java

Copyright, Info

class PathElementNotFound { }

Output:

warning: [path] bad path element "DoesNotExist": no such file or directory 1 warning

PkgClashWithClass

p/q.java
Copyright, Info

// Note: class p.q.C also exists package p; public class q { }

p/q/C.java
Copyright

package p.q; public class C { }

Output:

examples/PkgClashWithClass/p/q.java:31: error: class q clashes with package of same name public class q { } ^ examples/PkgClashWithClass/p/q/C.java:24: error: package p.q clashes with class of same name package p.q; ^ 2 errors

PossibleFallThrough.java

Copyright, Info

class PossibleFallThrough { void m(int i) { switch (i) { case 0: System.out.println(0); case 1: System.out.println(1); } } }

Output:

examples/PossibleFallThrough.java:32: warning: [fallthrough] possible fall-through into case case 1: ^ 1 warning

PossibleLossPrecision.java

Copyright, Info

class PossibleLossPrecision { long l; int i = l; }

Output:

examples/PossibleLossPrecision.java:29: error: incompatible types: possible lossy conversion from long to int int i = l; ^ 1 error

PotentialLambdaFound.java

Copyright, Info

class PotentialLambdaFound { interface SAM { void m(); } SAM s = new SAM() { public void m() { } }; }

Output:

examples/PotentialLambdaFound.java:33: Note: This anonymous inner class creation can be turned into a lambda expression. SAM s = new SAM() { public void m() { } }; ^

PrematureEOF.java

Copyright, Info

class PrematureEOF {

Output:

examples/PrematureEOF.java:26: error: reached end of file while parsing class PrematureEOF { ^ 1 error

PrintProcessorInfo

PrintProcessorInfo.java
Copyright, Info

class PrintProcessorInfo { }

processors/AnnoProc.java
Copyright

import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; @SupportedAnnotationTypes("*") public class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { return true; } public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } }

Output:

Processor AnnoProc matches [] and returns true.

PrintRounds

PrintRounds.java
Copyright, Info

class PrintRounds { }

processors/AnnoProc.java
Copyright

import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; @SupportedAnnotationTypes("*") public class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { return true; } public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } }

Output:

Round 1: input files: {PrintRounds} annotations: [] last round: false Round 2: input files: {} annotations: [] last round: true

ProbFoundReqFragment.java

Copyright, Info

class ProbFoundReqFragment { interface I { void g(int i); } void m(String s) { } void test() { I i = this::m; } }

Output:

examples/ProbFoundReqFragment.java:42: error: incompatible types: invalid method reference I i = this::m; ^ incompatible types: int cannot be converted to String 1 error

ProcCantFindClass

ProcCantFindClass.java
Copyright, Info

processors/AnnoProc.java
Copyright

import java.util.*; import javax.annotation.processing.*; import javax.lang.model.element.*; public class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { return true; } }

Output:

error: Could not find class file for 'UnknownClass'. 1 error

ProcFileCreateLastRound

ProcFileCreateLastRound.java
Copyright, Info

class ProcFileCreateLastRound { }

processors/AnnoProc.java
Copyright

import java.io.*; import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; import javax.tools.*; @SupportedAnnotationTypes("*") public class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { if (renv.processingOver()) { Filer filer = processingEnv.getFiler(); Messager messager = processingEnv.getMessager(); try { JavaFileObject fo = filer.createSourceFile("Gen"); Writer out = fo.openWriter(); out.write("class Gen { }"); out.close(); } catch (IOException e) { messager.printMessage(Diagnostic.Kind.ERROR, e.toString()); } } return false; } public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } }

Output:

warning: File for type 'Gen' created in the last round will not be subject to annotation processing. 1 warning

ProcFileReopening

ProcFileReopening.java
Copyright, Info

class ProcFileReopening { }

processors/AnnoProc.java
Copyright

import java.io.*; import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; import javax.tools.*; @SupportedAnnotationTypes("*") public class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { if (++round == 1) { Filer filer = processingEnv.getFiler(); Messager messager = processingEnv.getMessager(); try { FileObject fo1 = filer.createResource( StandardLocation.CLASS_OUTPUT, "", "HelloWorld.txt"); Writer out = fo1.openWriter(); out.write("Hello World!"); out.close(); FileObject fo2 = filer.createResource( StandardLocation.CLASS_OUTPUT, "", "HelloWorld.txt"); } catch (IOException e) { messager.printMessage(Diagnostic.Kind.ERROR, e.toString()); } } return false; } public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } int round = 0; }

Output:

warning: Attempt to create a file for '/tmp/RunExamples2271864106063728804/classes/HelloWorld.txt' multiple times error: javax.annotation.processing.FilerException: Attempt to reopen a file for path /tmp/RunExamples2271864106063728804/classes/HelloWorld.txt 1 error 1 warning

ProcIllegalFileName

ProcIllegalFileName.java
Copyright, Info

class ProcIllegalFileName { }

processors/AnnoProc.java
Copyright

import java.io.*; import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; import javax.tools.*; @SupportedAnnotationTypes("*") public class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { if (++round == 1) { Filer filer = processingEnv.getFiler(); Messager messager = processingEnv.getMessager(); try { FileObject fo1 = filer.createResource( StandardLocation.CLASS_OUTPUT, "p+q", "Hello-World.txt"); Writer out = fo1.openWriter(); out.write("Hello World!"); out.close(); } catch (IOException e) { messager.printMessage(Diagnostic.Kind.ERROR, e.toString()); } } return false; } public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } int round = 0; }

Output:

warning: Cannot create file for illegal name 'p+q'. error: javax.annotation.processing.FilerException: Illegal name p+q 1 error 1 warning

ProcIncompatibleSourceVersion

ProcIncompatibleSourceVersion.java
Copyright, Info

class ProcIncompatibleSourceVersion { }

processors/AnnoProc.java
Copyright

import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; @SupportedSourceVersion(SourceVersion.RELEASE_6) @SupportedAnnotationTypes("*") public class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { return true; } }

Output:

warning: Supported source version 'RELEASE_6' from annotation processor 'AnnoProc' less than -source '1.8' 1 warning

ProcOnlyNoProcs.java

Copyright, Info

Output:

warning: Annotation processing without compilation requested but no processors were found. 1 warning

ProcPackageDoesNotExist

ProcPackageDoesNotExist.java
Copyright, Info

processors/AnnoProc.java
Copyright

import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; @SupportedAnnotationTypes("*") public class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { return true; } public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } }

Output:

warning: package Unknown.Package does not exist 1 warning

ProcSuspiciousClassName

ProcSuspiciousClassName.java
Copyright, Info

class ProcSuspiciousClassName { }

processors/AnnoProc.java
Copyright

import java.io.*; import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; import javax.tools.*; @SupportedAnnotationTypes("*") public class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { if (++round == 1) { Filer filer = processingEnv.getFiler(); Messager messager = processingEnv.getMessager(); try { FileObject fo = filer.createSourceFile("HelloWorld.java"); try (Writer out = fo.openWriter()) { out.write("class HelloWorld {\n"); out.write(" public static void main(String[] args) {\n"); out.write(" System.out.println(\"Hello World!\");\n"); out.write(" }\n"); out.write("}\n"); } } catch (IOException e) { messager.printMessage(Diagnostic.Kind.ERROR, e.toString()); } } return false; } public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } int round = 0; }

Output:

warning: Creating file for a type whose name ends in .java: 'HelloWorld.java' 1 warning

ProcTypeRecreate

ProcTypeRecreate.java
Copyright, Info

class ProcTypeRecreate { }

processors/AnnoProc.java
Copyright

import java.io.*; import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; import javax.tools.*; @SupportedAnnotationTypes("*") public class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { round++; if (round <= 2) { Filer filer = processingEnv.getFiler(); Messager messager = processingEnv.getMessager(); try { JavaFileObject fo = filer.createSourceFile("Gen"); Writer out = fo.openWriter(); out.write("class Gen { }"); out.close(); } catch (IOException e) { messager.printMessage(Diagnostic.Kind.ERROR, e.toString()); } } return false; } public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } int round; }

Output:

warning: Attempt to create a file for type 'Gen' multiple times error: javax.annotation.processing.FilerException: Attempt to recreate a file for type Gen 1 error 1 warning

ProcUnclosedTypeFiles

ProcUnclosedTypeFiles.java
Copyright, Info

class ProcUnclosedTypeFiles { }

processors/AnnoProc.java
Copyright

import java.io.*; import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; import javax.tools.*; @SupportedAnnotationTypes("*") public class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { if (first) { Filer filer = processingEnv.getFiler(); Messager messager = processingEnv.getMessager(); try { JavaFileObject fo = filer.createSourceFile("Gen"); Writer out = fo.openWriter(); out.write("class Gen { }"); //out.close(); } catch (IOException e) { messager.printMessage(Diagnostic.Kind.ERROR, e.toString()); } first = false; } return false; } public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } boolean first = true; }

Output:

warning: Unclosed files for the types '[Gen]'; these types will not undergo annotation processing 1 warning

ProcUseImplicit

ProcUseImplicit.java
Copyright, Info

import p.SomeClass; @Deprecated class ProcUseImplicit extends SomeClass { }

sourcepath/p/SomeClass.java
Copyright

package p; public class SomeClass { }

processors/AnnoProc.java
Copyright

import java.io.*; import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; import javax.tools.*; @SupportedAnnotationTypes("*") public class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { if ((++round) == 1) { Filer filer = processingEnv.getFiler(); Messager messager = processingEnv.getMessager(); try { JavaFileObject fo = filer.createSourceFile("Gen"); Writer out = fo.openWriter(); out.write("class Gen { }"); out.close(); } catch (IOException e) { messager.printMessage(Diagnostic.Kind.ERROR, e.toString()); } } return true; } public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } int round; }

Output:

warning: Implicitly compiled files were not subject to annotation processing. Use -implicit to specify a policy for implicit compilation. 1 warning

ProcUseProcOrImplicit

ProcUseProcOrImplicit.java
Copyright, Info

import p.SomeClass; @Deprecated class ProcUseProcOrImplicit extends SomeClass { }

sourcepath/p/SomeClass.java
Copyright

package p; public class SomeClass { }

processors/AnnoProc.java
Copyright

import java.io.*; import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; import javax.tools.*; @SupportedAnnotationTypes("*") public class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { if ((++round) == 1) { Filer filer = processingEnv.getFiler(); Messager messager = processingEnv.getMessager(); try { JavaFileObject fo = filer.createSourceFile("Gen"); Writer out = fo.openWriter(); out.write("class Gen { }"); out.close(); } catch (IOException e) { messager.printMessage(Diagnostic.Kind.ERROR, e.toString()); } } return true; } public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } int round; }

Output:

warning: Implicitly compiled files were not subject to annotation processing. Use -proc:none to disable annotation processing or -implicit to specify a policy for implicit compilation. 1 warning

ProcessorCantInstantiate

ProcessorCantInstantiate.java
Copyright, Info

class ProcessorCantInstantiate { }

processors/AnnoProc.java
Copyright

import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; @SupportedAnnotationTypes("*") class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { return true; } public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } }

Output:

error: Could not instantiate an instance of processor 'AnnoProc' 1 error

ProcessorNotFound.java

Copyright, Info

class ProcessorNotFound { }

Output:

error: Annotation processor 'Unknown.Processor' not found 1 error

ProcessorWrongType

ProcessorWrongType.java
Copyright, Info

clas ProcessorWrongType { }

processors/AnnoProc.java
Copyright

public class AnnoProc { }

Output:

error: Annotation processor 'AnnoProc' does not implement javax.annotation.processing.Processor 1 error

QualifiedNewStaticClass.java

Copyright, Info

class QualifiedNewStaticClass { static class C { } QualifiedNewStaticClass x; C c = x.new C(); }

Output:

examples/QualifiedNewStaticClass.java:29: error: qualified new of static class C c = x.new C(); ^ 1 error

RawClassUse.java

Copyright, Info

import java.util.*; class RawClassUse { ArrayList l; }

Output:

examples/RawClassUse.java:30: warning: [rawtypes] found raw type: ArrayList ArrayList l; ^ missing type arguments for generic class ArrayList<E> where E is a type-variable: E extends Object declared in class ArrayList 1 warning

ReceiverParameterNotApplicableConstructor.java

Copyright, Info

class ReceiverParameterNotApplicableConstructor { ReceiverParameterNotApplicableConstructor(ReceiverParameterNotApplicableConstructor this) { } }

Output:

examples/ReceiverParameterNotApplicableConstructor.java:27: error: receiver parameter not applicable for constructor of top-level class ReceiverParameterNotApplicableConstructor(ReceiverParameterNotApplicableConstructor this) { } ^ 1 error

RecursiveConstrInvocation.java

Copyright, Info

class X { X() { this(); } }

Output:

examples/RecursiveConstrInvocation.java:27: error: recursive constructor invocation X() { ^ 1 error

RedundantCast.java

Copyright, Info

class RedundantCast { int i = (int) 0; }

Output:

examples/RedundantCast.java:28: warning: [cast] redundant cast to int int i = (int) 0; ^ 1 warning

RedundantSupertype.java

Copyright, Info

class RedundantSupertype { interface I { default void m() { } } interface J extends I { default void m() { } } static class C implements I, J { void foo() { I.super.m(); } } }

Output:

examples/RedundantSupertype.java:32: error: bad type qualifier I in default super call void foo() { I.super.m(); } ^ redundant interface I is extended by J 1 error

RefAmbiguous.java

Copyright, Info

class X { void m(int i, double d) { } void m(double d, int m) { } { m(1, 2); } }

Output:

examples/RefAmbiguous.java:31: error: reference to m is ambiguous m(1, 2); ^ both method m(int,double) in X and method m(double,int) in X match 1 error

RefAmbiguousFragment.java

Copyright, Info

class RefAmbiguousFragment { interface SAM { void m(Integer i1, Integer i2); } void f(Number n, Integer i) { } void f(Integer i, Number n) { } void test() { SAM s = RefAmbiguousFragment::f; } }

Output:

examples/RefAmbiguousFragment.java:38: error: incompatible types: invalid method reference SAM s = RefAmbiguousFragment::f; ^ reference to f is ambiguous both method f(Number,Integer) in RefAmbiguousFragment and method f(Integer,Number) in RefAmbiguousFragment match 1 error

RefBadParens.java

Copyright, Info

/** @see #m((int)) */ class RefBadParens { }

Output:

Note: ')' missing in reference

RefIdentifierExpected.java

Copyright, Info

class IdentifierExpected2 { /** @param 123 */ void m() { } }

Output:

Note: identifier expected

RefSyntaxError.java

Copyright, Info

/** @see #m(int [) */ class RefSyntaxError { }

Output:

Note: syntax error in reference

RefUnexpectedInput.java

Copyright, Info

/** @see String#isEmpty% */ class UnexpectedInput { }

Output:

Note: unexpected text

RepeatableDocumentedMismatch.java

Copyright, Info

import java.lang.annotation.*; @Documented @Repeatable(Annos.class) @interface Anno { } @interface Annos { Anno[] value(); } @Anno @Anno class RepeatableDocumentedMismatch { }

Output:

examples/RepeatableDocumentedMismatch.java:29: error: containing annotation type, Annos, is not @Documented while repeated annotation type, Anno, is @Repeatable(Annos.class) ^ 1 error

RepeatableInheritedMismatch.java

Copyright, Info

import java.lang.annotation.*; @Inherited @Repeatable(Annos.class) @interface Anno { } @interface Annos { Anno[] value(); } @Anno @Anno class RepeatableInheritedMismatch { }

Output:

examples/RepeatableInheritedMismatch.java:29: error: containing annotation type, Annos, is not @Inherited while repeated annotation type, Anno, is @Repeatable(Annos.class) ^ 1 error

RepeatableNoValue.java

Copyright, Info

import java.lang.annotation.*; @Repeatable(Annos.class) @interface Anno { } @interface Annos {} @Anno @Anno class RepeatableNoValue { }

Output:

examples/RepeatableNoValue.java:33: error: duplicate annotation: Annos is not a valid Repeatable, no value element method declared @Anno ^ examples/RepeatableNoValue.java:34: error: duplicate annotation: Annos is not a valid Repeatable, no value element method declared @Anno ^ examples/RepeatableNoValue.java:28: error: duplicate annotation: Annos is not a valid Repeatable, no value element method declared @Repeatable(Annos.class) ^ 3 errors

RepeatableNonDefault.java

Copyright, Info

import java.lang.annotation.*; @Repeatable(Annos.class) @interface Anno { } @interface Annos { Anno[] value(); String foo(); } class RepeatableNonDefault { }

Output:

examples/RepeatableNonDefault.java:28: error: containing annotation Annos does not have a default value for element foo() @Repeatable(Annos.class) ^ 1 error

RepeatableRetentionMismatch.java

Copyright, Info

import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME) @Repeatable(Annos.class) @interface Anno { } @interface Annos { Anno[] value(); } @Anno @Anno class RepeatableRetentionMismatch { }

Output:

examples/RepeatableRetentionMismatch.java:29: error: containing annotation Annos has shorter retention (CLASS) than the contained annotation Anno with retention RUNTIME @Repeatable(Annos.class) ^ 1 error

RepeatableTargetMismatch.java

Copyright, Info

import java.lang.annotation.*; @Repeatable(Annos.class) @Target(ElementType.METHOD) @interface Anno { } @interface Annos { Anno[] value(); } class RepeatableTargetMismatch { }

Output:

examples/RepeatableTargetMismatch.java:28: error: target of container annotation Annos is not a subset of target of repeated annotation Anno @Repeatable(Annos.class) ^ 1 error

RepeatableWrongValueType.java

Copyright, Info

import java.lang.annotation.*; @Repeatable(Annos.class) @interface Anno { } @interface Annos { String value(); } @Anno @Anno class RepeatableWrongValueType { }

Output:

examples/RepeatableWrongValueType.java:33: error: duplicate annotation: value element of containing annotation Annos should have type Anno[], found String @Anno ^ examples/RepeatableWrongValueType.java:34: error: duplicate annotation: value element of containing annotation Annos should have type Anno[], found String @Anno ^ examples/RepeatableWrongValueType.java:28: error: duplicate annotation: value element of containing annotation Annos should have type Anno[], found String @Repeatable(Annos.class) ^ 3 errors

RepeatedAnnotationTarget.java

Copyright, Info

import java.lang.annotation.*; @Target({ElementType.FIELD, ElementType.FIELD}) @interface X { }

Output:

examples/RepeatedAnnotationTarget.java:28: error: repeated annotation target @Target({ElementType.FIELD, ElementType.FIELD}) ^ 1 error

RepeatedInterface.java

Copyright, Info

interface I { } class RepeatedInterface implements I, I { }

Output:

examples/RepeatedInterface.java:29: error: repeated interface implements I, I ^ 1 error

RepeatedModifier.java

Copyright, Info

class RepeatedModifier { public public String toString() { return "??"; } }

Output:

examples/RepeatedModifier.java:27: error: repeated modifier public public String toString() { return "??"; } ^ 1 error

RepeatingAnnotationAndContainer.java

Copyright, Info

import java.lang.annotation.*; @Repeatable(Annos.class) @interface Anno { } @interface Annos { Anno[] value(); } @Anno @Anno @Annos(@Anno) class RepeatingAnnotationAndContainer { }

Output:

examples/RepeatingAnnotationAndContainer.java:35: error: container Annos must not be present at the same time as the element it contains @Annos(@Anno) ^ 1 error

ReportAccess.java

Copyright, Info

class ReportAccess { int i = new Other().x; } class Other { private int x; }

Output:

examples/ReportAccess.java:27: error: x has private access in Other int i = new Other().x; ^ 1 error

ResourceClosed.java

Copyright, Info

import java.io.*; class ResourceClosed { void m() throws IOException { try (Writer out = new StringWriter()) { out.close(); } } }

Output:

examples/ResourceClosed.java:32: warning: [try] explicit call to close() on an auto-closeable resource out.close(); ^ 1 warning

ResourceMayNotBeAssigned.java

Copyright, Info

import java.io.*; class ResourceMayNotBeAssigned { void m(File f) { try (Writer out = new StringWriter()) { out = null; } } }

Output:

examples/ResourceMayNotBeAssigned.java:31: error: auto-closeable resource out may not be assigned out = null; ^ 1 error

ResourceNotApplicableToType.java

Copyright, Info

class ResourceNotApplicableToType { void m() { try (String s = "") { } } }

Output:

examples/ResourceNotApplicableToType.java:30: error: incompatible types: try-with-resources not applicable to variable type try (String s = "") { ^ (String cannot be converted to AutoCloseable) 1 error

ResourceNotReferenced.java

Copyright, Info

import java.io.*; class ResourceNotReferenced { void m() throws IOException { try (Writer out = new StringWriter()) { } } }

Output:

examples/ResourceNotReferenced.java:31: warning: [try] auto-closeable resource out is never referenced in body of corresponding try statement try (Writer out = new StringWriter()) { ^ 1 warning

ReturnOutsideMethod.java

Copyright, Info

class ReturnOutsideMethod { { return; } }

Output:

examples/ReturnOutsideMethod.java:27: error: return outside method { return; } ^ 1 error

SourceNoBootclasspath.java

Copyright, Info

class SourceNoBootclasspath { }

Output:

warning: [options] bootstrap class path not set in conjunction with -source 1.6 1 warning

StaticBoundMref.java

Copyright, Info

class StaticBoundMref { Runnable r = new StaticBoundMref()::m; static void m() { } }

Output:

examples/StaticBoundMref.java:29: error: invalid method reference Runnable r = new StaticBoundMref()::m; ^ static bound method reference 1 error

StaticImportNotSupported.java

Copyright, Info

import static java.util.regex.Pattern.*; class StaticImportNotSupported { }

Output:

examples/StaticImportNotSupported.java:27: error: static import declarations are not supported in -source 1.4 import static java.util.regex.Pattern.*; ^ (use -source 5 or higher to enable static import declarations) 1 error

StaticImportOnlyClassesAndInterfaces

StaticImportOnlyClassesAndInterfaces.java
Copyright, Info

import static p.Other.array.length; class StaticImportOnlyClassesAndInterfaces { }

Other.java
Copyright

package p; public class Other { public static int[] array; }

Output:

examples/StaticImportOnlyClassesAndInterfaces/StaticImportOnlyClassesAndInterfaces.java:28: error: cannot find symbol import static p.Other.array.length; ^ symbol: class array location: class Other examples/StaticImportOnlyClassesAndInterfaces/StaticImportOnlyClassesAndInterfaces.java:28: error: static import only from classes and interfaces import static p.Other.array.length; ^ 2 errors

StaticIntfMethodNotSupported.java

Copyright, Info

interface StaticIntfMethodNotSupported { static void m() { } }

Output:

examples/StaticIntfMethodNotSupported.java:28: error: static interface methods are not supported in -source 1.7 static void m() { } ^ (use -source 8 or higher to enable static interface methods) 1 error

StaticMethodInUnboundLookup.java

Copyright, Info

class StaticBoundMref { interface SAM { void m(StaticBoundMref m); } SAM s = StaticBoundMref::m; static void m() { } }

Output:

examples/StaticMethodInUnboundLookup.java:33: error: invalid method reference SAM s = StaticBoundMref::m; ^ static method m() found in unbound lookup 1 error

StaticMrefWithTargs.java

Copyright, Info

class StaticMrefWithTargs<X> { Runnable r = StaticMrefWithTargs<String>::m; static void m() { } }

Output:

examples/StaticMrefWithTargs.java:29: error: invalid method reference Runnable r = StaticMrefWithTargs<String>::m; ^ parameterized qualifier on static method reference 1 error

StaticNotQualifiedByType.java

Copyright, Info

class StaticNotQualifiedByType { int m(Other other) { return other.i; } } class Other { static int i; }

Output:

examples/StaticNotQualifiedByType.java:29: warning: [static] static variable should be qualified by type name, Other, instead of by an expression return other.i; ^ 1 warning

StringConstRequired.java

Copyright, Info

class StringConstRequired { String s = "three"; int m(String arg) { switch (arg) { case "one": return 1; case "two": return 2; case s: return 3; } } }

Output:

examples/StringConstRequired.java:33: error: constant string expression required case s: return 3; ^ 1 error

StringSwitchNotSupported.java

Copyright, Info

class StringSwitchNotSupported { int m(String s) { switch (s) { case "one": return 1; case "two": return 2; default: return -1; } } }

Output:

examples/StringSwitchNotSupported.java:29: error: strings in switch are not supported in -source 1.6 switch (s) { ^ (use -source 7 or higher to enable strings in switch) 1 error

SunApiFilename.java

Copyright, Info

class SunApiFilename { sun.misc.Unsafe x; }

Output:

Note: examples/SunApiFilename.java uses internal proprietary API that may be removed in a future release. Note: Recompile with -Xlint:sunapi for details.

SunApiFilenameAdditional.java

Copyright, Info

class SunApiFilenameAdditional { sun.misc.Unsafe x1; sun.misc.Unsafe x2; }

Output:

examples/SunApiFilenameAdditional.java:29: warning: Unsafe is internal proprietary API and may be removed in a future release sun.misc.Unsafe x1; ^ Note: examples/SunApiFilenameAdditional.java uses additional internal proprietary API that may be removed in a future release. 1 warning

SunApiPlural

SunApiPlural.java
Copyright, Info

class SunApiPlural { sun.misc.Unsafe x; }

SunApiFilename.java
Copyright

class SunApiFilename { sun.misc.Unsafe x; }

Output:

Note: Some input files use internal proprietary API that may be removed in a future release. Note: Recompile with -Xlint:sunapi for details.

SunApiPluralAdditional

SunApiPluralAdditional.java
Copyright, Info

class SunApiPluralAdditional { sun.misc.Unsafe x; }

SunApiFilename.java
Copyright

class SunApiFilename { sun.misc.Unsafe x; }

SunApiPlural.java
Copyright

class SunApiPlural { sun.misc.Unsafe x; }

Output:

examples/SunApiPluralAdditional/SunApiPlural.java:25: warning: Unsafe is internal proprietary API and may be removed in a future release sun.misc.Unsafe x; ^ Note: Some input files additionally use internal proprietary API that may be removed in a future release. 1 warning

SunProprietary.java

Copyright, Info

class SunProprietary { sun.misc.Unsafe x; }

Output:

examples/SunProprietary.java:27: warning: Unsafe is internal proprietary API and may be removed in a future release sun.misc.Unsafe x; ^ 1 warning

SuperNotAllowedInEnum.java

Copyright, Info

enum SuperNotAllowedInEnum { A, B, C; SuperNotAllowedInEnum() { super(); } }

Output:

examples/SuperNotAllowedInEnum.java:31: error: call to super not allowed in enum constructor super(); ^ 1 error

ThisAsIdentifier.java

Copyright, Info

class ThisAsIdentifier { Object this; }

Output:

examples/ThisAsIdentifier.java:27: error: as of release 8, 'this' is allowed as the parameter name for the receiver type only, which has to be the first parameter Object this; ^ 1 error

ThrowsNotAllowedInAnno.java

Copyright, Info

@interface ThrowsNotAllowedInAnno { String value() throws NullPointerException; }

Output:

examples/ThrowsNotAllowedInAnno.java:27: error: throws clause not allowed in @interface members String value() throws NullPointerException; ^ 1 error

TrustMeOnNonVarargsMeth.java

Copyright, Info

class TrustMeOnNonVarargsMeth { @SafeVarargs static void m(String[] args) { } }

Output:

examples/TrustMeOnNonVarargsMeth.java:29: error: Invalid SafeVarargs annotation. Method m(String[]) is not a varargs method. @SafeVarargs static void m(String[] args) { } ^ 1 error

TrustMeOnReifiableVarargsParam.java

Copyright, Info

class TrustMeOnReifiableVarargsParam { @SafeVarargs static void m(String... args) { } }

Output:

examples/TrustMeOnReifiableVarargsParam.java:29: warning: [varargs] Redundant SafeVarargs annotation. Varargs element type String is reifiable. @SafeVarargs static void m(String... args) { } ^ 1 warning

TrustMeOnVirtualMethod.java

Copyright, Info

import java.util.List; class TrustMeOnVirtualMethod { @SafeVarargs void m(List<String>... args) { } }

Output:

examples/TrustMeOnVirtualMethod.java:31: error: Invalid SafeVarargs annotation. Instance method m(List<String>...) is not final. @SafeVarargs void m(List<String>... args) { } ^ 1 error

TryResourceNotSupported.java

Copyright, Info

import java.io.*; class TryResourceNotSupported { void m() { try (Writer out = new StringWriter()) { out.println("Hello World"); } } }

Output:

examples/TryResourceNotSupported.java:31: error: try-with-resources is not supported in -source 1.6 try (Writer out = new StringWriter()) { ^ (use -source 7 or higher to enable try-with-resources) 1 error

TryResourceThrowsInterruptedExc.java

Copyright, Info

class TryResourceThrowsInterruptedException implements AutoCloseable { public void close() throws InterruptedException {} }

Output:

examples/TryResourceThrowsInterruptedExc.java:27: warning: [try] auto-closeable resource TryResourceThrowsInterruptedException has a member method close() that could throw InterruptedException class TryResourceThrowsInterruptedException implements AutoCloseable { ^ 1 warning

TryWithoutCatchOrFinally.java

Copyright, Info

class TryWithoutCatchOrFinally { void m() { try { } } }

Output:

examples/TryWithoutCatchOrFinally.java:29: error: 'try' without 'catch' or 'finally' try { ^ 1 error

TryWithoutCatchOrFinallyOrResource.java

Copyright, Info

class TryWithoutCatchOrFinallyOrResource { void m() { try { } } }

Output:

examples/TryWithoutCatchOrFinallyOrResource.java:28: error: 'try' without 'catch', 'finally' or resource declarations try { ^ 1 error

TypeAnnotationsNotSupported.java

Copyright, Info

@interface Anno { } class TypeAnnotationsNotSupported { void m() { int i = (@Anno int) 3.14; } }

Output:

warning: [options] bootstrap class path not set in conjunction with -source 1.6 examples/TypeAnnotationsNotSupported.java:32: error: type annotations are not supported in -source 1.6 int i = (@Anno int) 3.14; ^ (use -source 8 or higher to enable type annotations) 1 error 1 warning

TypeFoundRequired.java

Copyright, Info

import java.util.*; class X<T> { List<T<Integer>> list; }

Output:

examples/TypeFoundRequired.java:31: error: unexpected type List<T<Integer>> list; ^ required: class found: type parameter T where T is a type-variable: T extends Object declared in class X 1 error

TypeNoParams.java

Copyright, Info

class TypeNoParams { Object<Integer> obj; }

Output:

examples/TypeNoParams.java:27: error: type Object does not take parameters Object<Integer> obj; ^ 1 error

TypeReqClassArray.java

Copyright, Info

import java.util.*; class TypeReqClassArray { boolean b = (this instanceof int); }

Output:

examples/TypeReqClassArray.java:30: error: unexpected type boolean b = (this instanceof int); ^ required: class or array found: int 1 error

TypeReqRef.java

Copyright, Info

class TypeReqRef { int i; boolean b = (i instanceof Object); }

Output:

examples/TypeReqRef.java:29: error: unexpected type boolean b = (i instanceof Object); ^ required: reference found: int 1 error

TypeVarCantBeDeref.java

Copyright, Info

class Base<T> { } class TypeVarCantBeDeref<T> extends Base<T.foo> {}

Output:

examples/TypeVarCantBeDeref.java:28: error: cannot select from a type variable class TypeVarCantBeDeref<T> extends Base<T.foo> {} ^ 1 error

TypeVarMayNotBeFollowedByOtherBounds.java

Copyright, Info

import java.util.*; class X<T, U, V extends T & U> { }

Output:

examples/TypeVarMayNotBeFollowedByOtherBounds.java:28: error: a type variable may not be followed by other bounds class X<T, U, V extends T & U> { } ^ 1 error

TypesIncompatible.java

Copyright, Info

interface A { int m(); } interface B { String m(); } interface TypesIncompatible extends A, B { }

Output:

examples/TypesIncompatible.java:34: error: types B and A are incompatible; both define m(), but with unrelated return types interface TypesIncompatible extends A, B { } ^ 1 error

TypesIncompatibleAbstractDefault.java

Copyright, Info

class TypesIncompatibleAbstractDefault { interface A { default void m() { } } interface B { void m(); } interface AB extends A, B { } }

Output:

examples/TypesIncompatibleAbstractDefault.java:35: error: interface AB inherits abstract and default for m() from types A and B interface AB extends A, B { } ^ 1 error

TypesIncompatibleUnrelatedDefaults.java

Copyright, Info

class TypesIncompatibleUnrelatedDefaults { interface A { default void m() { } } interface B { default void m() { } } interface AB extends A, B { } }

Output:

examples/TypesIncompatibleUnrelatedDefaults.java:35: error: interface AB inherits unrelated defaults for m() from types A and B interface AB extends A, B { } ^ 1 error

UncheckedAssign.java

Copyright, Info

import java.util.*; class UncheckedAssign { void m(List l1, List<String> l2) { l2 = l1; } }

Output:

examples/UncheckedAssign.java:32: warning: [unchecked] unchecked conversion l2 = l1; ^ required: List<String> found: List 1 warning

UncheckedAssignToVar.java

Copyright, Info

class Foo<T> { T t; } class UncheckedAssignToVar { void m() { Foo f = new Foo(); f.t = "??"; } }

Output:

examples/UncheckedAssignToVar.java:34: warning: [unchecked] unchecked assignment to variable t as member of raw type Foo f.t = "??"; ^ 1 warning

UncheckedCall.java

Copyright, Info

import java.util.*; class UncheckedCall { void m() { List l = new ArrayList<String>(); l.add(1); } }

Output:

examples/UncheckedCall.java:32: warning: [unchecked] unchecked call to add(E) as a member of the raw type List l.add(1); ^ where E is a type-variable: E extends Object declared in interface List 1 warning

UncheckedCast.java

Copyright, Info

import java.util.*; class UncheckedCast { <T,U> List<U> m(List<T> l) { return (List<U>) l; } }

Output:

examples/UncheckedCast.java:32: warning: [unchecked] unchecked cast return (List<U>) l; ^ required: List<U> found: List<T> where T,U are type-variables: T extends Object declared in method <T,U>m(List<T>) U extends Object declared in method <T,U>m(List<T>) 1 warning

UncheckedClash.java

Copyright, Info

import java.util.*; interface Intf { List<String> m(); } interface UncheckedClash extends Intf { public List m(); }

Output:

examples/UncheckedClash.java:35: warning: [unchecked] m() in UncheckedClash overrides m() in Intf public List m(); ^ return type requires unchecked conversion from List to List<String> 1 warning

UncheckedFilename.java

Copyright, Info

import java.util.*; class UncheckedFilename { List<String> list = new ArrayList(); }

Output:

Note: examples/UncheckedFilename.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.

UncheckedFilenameAdditional.java

Copyright, Info

import java.util.*; class UncheckedFilenameAdditional { List<String> list1 = new ArrayList(); List<String> list2 = new ArrayList(); List<String> list3 = new ArrayList(); List<String> list4 = new ArrayList(); List<String> list5 = new ArrayList(); }

Output:

examples/UncheckedFilenameAdditional.java:32: warning: [unchecked] unchecked conversion List<String> list1 = new ArrayList(); ^ required: List<String> found: ArrayList examples/UncheckedFilenameAdditional.java:33: warning: [unchecked] unchecked conversion List<String> list2 = new ArrayList(); ^ required: List<String> found: ArrayList examples/UncheckedFilenameAdditional.java:34: warning: [unchecked] unchecked conversion List<String> list3 = new ArrayList(); ^ required: List<String> found: ArrayList Note: examples/UncheckedFilenameAdditional.java has additional unchecked or unsafe operations. 3 warnings

UncheckedGenericArrayCreation.java

Copyright, Info

class UncheckedGenericArrayCreation<T> { void m(T t1, T t2, T t3) { show(t1, t2, t3); } void show(T... items) { } }

Output:

examples/UncheckedGenericArrayCreation.java:30: warning: [unchecked] unchecked generic array creation for varargs parameter of type T[] show(t1, t2, t3); ^ where T is a type-variable: T extends Object declared in class UncheckedGenericArrayCreation examples/UncheckedGenericArrayCreation.java:33: warning: [unchecked] Possible heap pollution from parameterized vararg type T void show(T... items) { ^ where T is a type-variable: T extends Object declared in class UncheckedGenericArrayCreation 2 warnings

UncheckedImplement.java

Copyright, Info

import java.util.*; interface Intf { List<String> m(); } class UncheckedImplement implements Intf { public List m() { return null; } }

Output:

examples/UncheckedImplement.java:35: warning: [unchecked] m() in UncheckedImplement implements m() in Intf public List m() { return null; } ^ return type requires unchecked conversion from List to List<String> 1 warning

UncheckedMethodInvocation.java

Copyright, Info

class UncheckedMethodInvocation { class X<T> {} public <T> void m(X<T> x, T t) {} public void test() { m(new X<X<Integer>>(), new X()); } }

Output:

examples/UncheckedMethodInvocation.java:35: warning: [unchecked] unchecked method invocation: method m in class UncheckedMethodInvocation is applied to given types m(new X<X<Integer>>(), new X()); ^ required: UncheckedMethodInvocation.X<T>,T found: UncheckedMethodInvocation.X<UncheckedMethodInvocation.X<Integer>>,UncheckedMethodInvocation.X where T is a type-variable: T extends Object declared in method <T>m(UncheckedMethodInvocation.X<T>,T) examples/UncheckedMethodInvocation.java:35: warning: [unchecked] unchecked conversion m(new X<X<Integer>>(), new X()); ^ required: UncheckedMethodInvocation.X<Integer> found: UncheckedMethodInvocation.X 2 warnings

UncheckedPlural

UncheckedPlural.java
Copyright, Info

import java.util.*; class UncheckedPlural { List<String> list = new ArrayList(); }

UncheckedFilename.java
Copyright

import java.util.*; class UncheckedFilename { List<String> list = new ArrayList(); }

Output:

Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.

UncheckedPluralAdditional

UncheckedPluralAdditional.java
Copyright, Info

import java.util.*; class UncheckedPluralAdditional { List<String> list = new ArrayList(); }

UncheckedFilename1.java
Copyright

import java.util.*; class UncheckedFilename1 { List<String> list = new ArrayList(); }

UncheckedFilename2.java
Copyright

import java.util.*; class UncheckedFilename2 { List<String> list = new ArrayList(); }

Output:

examples/UncheckedPluralAdditional/UncheckedFilename2.java:27: warning: [unchecked] unchecked conversion List<String> list = new ArrayList(); ^ required: List<String> found: ArrayList Note: Some input files additionally use unchecked or unsafe operations. 1 warning

UnclosedCharLiteral.java

Copyright, Info

class UnclosedCharLit { char c = 'a; }

Output:

examples/UnclosedCharLiteral.java:27: error: unclosed character literal char c = 'a; ^ 1 error

UnclosedComment.java

Copyright, Info

class UnclosedComment { /* void m() { } }

Output:

examples/UnclosedComment.java:28: error: unclosed comment /* ^ examples/UnclosedComment.java:31: error: reached end of file while parsing 2 errors

UnclosedStringLiteral.java

Copyright, Info

class UnclosedStringLit { String s = "abc; }

Output:

examples/UnclosedStringLiteral.java:27: error: unclosed string literal String s = "abc; ^ 1 error

UndefinedLabel.java

Copyright, Info

class LabelInUse { void m() { int[] values = { 1, 2, 3 }; for (int v: values) { if (v == 2) continue label; System.err.println(v); } } }

Output:

examples/UndefinedLabel.java:31: error: undefined label: label continue label; ^ 1 error

UnderscoreAsIdentifier.java

Copyright, Info

class UnderscoreAsIdentifier { String _ = null; }

Output:

examples/UnderscoreAsIdentifier.java:27: warning: '_' used as an identifier String _ = null; ^ (use of '_' as an identifier might not be supported in releases after Java SE 8) 1 warning

UnexpectedContent.java

Copyright, Info

/** {@docRoot a} */ class UnterminatedSignature { }

Output:

Note: unexpected content

UnexpectedLambda.java

Copyright, Info

class UnexpectedLambda { { (()-> { })++; } }

Output:

examples/UnexpectedLambda.java:27: error: lambda expression not expected here { (()-> { })++; } ^ 1 error

UnexpectedMref.java

Copyright, Info

class UnexpectedLambda { { (Foo::bar)++; } }

Output:

examples/UnexpectedMref.java:27: error: method reference not expected here { (Foo::bar)++; } ^ 1 error

UnexpectedReturnValue.java

Copyright, Info

class UnexpectedReturnValue { void m() { return 3; } }

Output:

examples/UnexpectedReturnValue.java:29: error: incompatible types: unexpected return value return 3; ^ 1 error

UnmatchedProcessorOptions

UnmatchedProcessorOptions.java
Copyright, Info

class UnmatchedProcessorOptions { }

processors/AnnoProc.java
Copyright

import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; @SupportedAnnotationTypes("*") @SupportedOptions({ "supportedOption" }) public class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { return true; } public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } }

Output:

warning: The following options were not recognized by any processor: '[unknownOption]'

UnnamedPackage.java

Copyright, Info

class UnnamedPackage { class UnnamedPackage { } }

Output:

examples/UnnamedPackage.java:30: error: class UnnamedPackage is already defined in package unnamed package class UnnamedPackage { } ^ 1 error

UnreachableCatch.java

Copyright, Info

class UnreachableCatch { void test() { try { throw new java.io.FileNotFoundException(); } catch(java.io.FileNotFoundException exc) { } catch(java.io.IOException exc) { } //unreachable } }

Output:

examples/UnreachableCatch.java:33: warning: unreachable catch clause catch(java.io.IOException exc) { } //unreachable ^ thrown type FileNotFoundException has already been caught 1 warning

UnreachableCatch1.java

Copyright, Info

import java.io.*; class UnreachableCatch1 { void test() { try { if (true) { throw new FileNotFoundException(); } else { throw new EOFException(); } } catch(FileNotFoundException fnf) { } catch(EOFException eof) { } catch(IOException ex) { } //unreachable } }

Output:

examples/UnreachableCatch1.java:41: warning: unreachable catch clause catch(IOException ex) { } //unreachable ^ thrown types FileNotFoundException,EOFException have already been caught 1 warning

UnreachableStatement.java

Copyright, Info

class X { void m() { return; m(); } }

Output:

examples/UnreachableStatement.java:29: error: unreachable statement m(); ^ 1 error

UnreportedException.java

Copyright, Info

class UnreportedException { void m() { throw new Exception(); } }

Output:

examples/UnreportedException.java:28: error: unreported exception Exception; must be caught or declared to be thrown throw new Exception(); ^ 1 error

UnreportedExceptionDefaultConstructor.java

Copyright, Info

class Base { Base() throws Exception { } } class UnreportedExceptionDefaultConstructor extends Base { }

Output:

examples/UnreportedExceptionDefaultConstructor.java:30: error: unreported exception Exception in default constructor class UnreportedExceptionDefaultConstructor extends Base { } ^ 1 error

UnreportedExceptionImplicitClose.java

Copyright, Info

class UnreportedExceptionImplicitClose { static class MyCloseable implements AutoCloseable { public void close() throws Exception { } } void test() { try (MyCloseable x = new MyCloseable()) { } } }

Output:

examples/UnreportedExceptionImplicitClose.java:31: error: unreported exception Exception; must be caught or declared to be thrown try (MyCloseable x = new MyCloseable()) { } ^ exception thrown from implicit call to close() on resource variable 'x' 1 error

UnsafeUseOfVarargsParam.java

Copyright, Info

class UnsafeUseOfVarargsParam { @SafeVarargs static <X> void m(X... x) { Object[] o = x; } }

Output:

examples/UnsafeUseOfVarargsParam.java:29: warning: [varargs] Varargs method could cause heap pollution from non-reifiable varargs parameter x Object[] o = x; ^ 1 warning

UnsupportedBinaryLiteral.java

Copyright, Info

class UnsupportedBinaryLiteral { int i = 0b01000010; }

Output:

examples/UnsupportedBinaryLiteral.java:28: error: binary literals are not supported in -source 1.6 int i = 0b01000010; ^ (use -source 7 or higher to enable binary literals) 1 error

UnsupportedEncoding.java

Copyright, Info

class UnsupportedEncoding { }

Output:

error: unsupported encoding: UNSUPPORTED java.lang.RuntimeException at com.sun.tools.javac.util.Log.writeDiagnostic(Log.java:633) at com.sun.tools.javac.util.Log$DefaultDiagnosticHandler.report(Log.java:600) at com.sun.tools.javac.util.Log.report(Log.java:562) at com.sun.tools.javac.util.AbstractLog.error(AbstractLog.java:84) at com.sun.tools.javac.util.BaseFileManager.decode(BaseFileManager.java:212) at com.sun.tools.javac.file.RegularFileObject.getCharContent(RegularFileObject.java:115) at com.sun.tools.javac.file.RegularFileObject.getCharContent(RegularFileObject.java:52) at com.sun.tools.javac.main.JavaCompiler.readSource(JavaCompiler.java:578) at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:641) at com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:926) at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:833) at com.sun.tools.javac.main.Main.compile(Main.java:518) at com.sun.tools.javac.main.Main.compile(Main.java:376) at com.sun.tools.javac.main.Main.compile(Main.java:365) at com.sun.tools.javac.main.Main.compile(Main.java:356) at com.sun.tools.javac.Main.compile(Main.java:95) at Example$SimpleCompiler.run(Example.java:476) at Example.run(Example.java:228) at Example.run(Example.java:162) at RunExamples$HTMLRunner.run(RunExamples.java:559) at RunExamples$Runner.run(RunExamples.java:239) at RunExamples$HTMLRunner.run(RunExamples.java:395) at RunExamples.run(RunExamples.java:161) at RunExamples.main(RunExamples.java:76) 1 error

UnsupportedFpLit.java

Copyright, Info

class UnsupportedFpLit { float f = 0xCafe.BabeP1; }

Output:

examples/UnsupportedFpLit.java:28: error: hexadecimal floating point literals are not supported in -source 1.4 float f = 0xCafe.BabeP1; ^ (use -source 5 or higher to enable hexadecimal floating point literals) 1 error

UnsupportedUnderscoreLiteral.java

Copyright, Info

class UnsupportedUnderscoreLiteral { int i = 123_456_789; }

Output:

examples/UnsupportedUnderscoreLiteral.java:28: error: underscores in literals are not supported in -source 1.6 int i = 123_456_789; ^ (use -source 7 or higher to enable underscores in literals) 1 error

UnterminatedInlineTag.java

Copyright, Info

/** {@code */ class UnterminatedInlineTag { }

Output:

Note: unterminated inline tag

UnterminatedSignature.java

Copyright, Info

/** @see String#equals( */ class UnterminatedSignature { }

Output:

Note: unterminated signature

VarMightAlreadyBeAssigned.java

Copyright, Info

class VarMightAlreadyBeAssigned { void m(boolean b) { final int i; if (b) i = 3; i = 4; } }

Output:

examples/VarMightAlreadyBeAssigned.java:31: error: variable i might already have been assigned i = 4; ^ 1 error

VarMightNotHaveBeenInitialized.java

Copyright, Info

class X { final int i; X(boolean b) { if (b) i = 3; } }

Output:

examples/VarMightNotHaveBeenInitialized.java:31: error: variable i might not have been initialized } ^ 1 error

VarargsAndOldArraySyntax.java

Copyright, Info

class VarargsAndOldArraySyntax { void m1 (Integer... i[]) { } }

Output:

examples/VarargsAndOldArraySyntax.java:27: error: legacy array notation not allowed on variable-arity parameter void m1 (Integer... i[]) { } ^ 1 error

VarargsAndReceiver.java

Copyright, Info

class VarargsAndReceiver { void m(VarargsAndReceiver... this) { } }

Output:

examples/VarargsAndReceiver.java:27: error: varargs notation not allowed on receiver parameter void m(VarargsAndReceiver... this) { } ^ 1 error

VarargsArgumentMismatch.java

Copyright, Info

class VarargsArgumentMismatch { void m(String s, Integer... is) {} { this.m("1", "2", "3"); } }

Output:

examples/VarargsArgumentMismatch.java:30: error: method m in class VarargsArgumentMismatch cannot be applied to given types; { this.m("1", "2", "3"); } ^ required: String,Integer[] found: String,String,String reason: varargs mismatch; String cannot be converted to Integer 1 error

VarargsClash.java

Copyright, Info

interface Base { void m(Object... x); } interface VarargsClash extends Base { void m(Object[] x); }

Output:

examples/VarargsClash.java:33: warning: m(Object[]) in VarargsClash overrides m(Object...) in Base; overriding method is missing '...' void m(Object[] x); ^ 1 warning

VarargsImplement.java

Copyright, Info

interface Base { void m(Object... x); } class VarargsImplement implements Base { public void m(Object[] x) { } }

Output:

examples/VarargsImplement.java:33: warning: m(Object[]) in VarargsImplement implements m(Object...) in Base; overriding method is missing '...' public void m(Object[] x) { } ^ 1 warning

VarargsNonReifiableType.java

Copyright, Info

class VarargsNonReifiableType<T> { void m(T... items) { } }

Output:

examples/VarargsNonReifiableType.java:28: warning: [unchecked] Possible heap pollution from parameterized vararg type T void m(T... items) { ^ where T is a type-variable: T extends Object declared in class VarargsNonReifiableType 1 warning

VarargsNotSupported.java

Copyright, Info

class VarargsNotSupported { void m(String... args) { } }

Output:

examples/VarargsNotSupported.java:28: error: variable-arity methods are not supported in -source 1.4 void m(String... args) { } ^ (use -source 5 or higher to enable variable-arity methods) 1 error

VarargsOverride.java

Copyright, Info

class Base { void m(Object... x) { } } class VarargsOverride extends Base { void m(Object[] x) { } }

Output:

examples/VarargsOverride.java:33: warning: m(Object[]) in VarargsOverride overrides m(Object...) in Base; overriding method is missing '...' void m(Object[] x) { } ^ 1 warning

Verbose.java

Copyright, Info

class Verbose { }

Output:

[parsing started RegularFileObject[examples/Verbose.java]] [parsing completed 0ms] [search path for source files: /w/jjg/work/tl/langtools/build/diag-examples/classes,/w/jjg/work/tl/langtools/dist/lib/javac.jar] [search path for class files: /opt/jdk/jdk1.8.0-b87/jre/lib/resources.jar,/opt/jdk/jdk1.8.0-b87/jre/lib/rt.jar,/opt/jdk/jdk1.8.0-b87/jre/lib/sunrsasign.jar,/opt/jdk/jdk1.8.0-b87/jre/lib/jsse.jar,/opt/jdk/jdk1.8.0-b87/jre/lib/jce.jar,/opt/jdk/jdk1.8.0-b87/jre/lib/charsets.jar,/opt/jdk/jdk1.8.0-b87/jre/lib/jfr.jar,/opt/jdk/jdk1.8.0-b87/jre/classes,/opt/jdk/jdk1.8.0-b87/jre/lib/ext/nashorn.jar,/opt/jdk/jdk1.8.0-b87/jre/lib/ext/sunjce_provider.jar,/opt/jdk/jdk1.8.0-b87/jre/lib/ext/sunec.jar,/opt/jdk/jdk1.8.0-b87/jre/lib/ext/localedata.jar,/opt/jdk/jdk1.8.0-b87/jre/lib/ext/dnsns.jar,/opt/jdk/jdk1.8.0-b87/jre/lib/ext/jfxrt.jar,/opt/jdk/jdk1.8.0-b87/jre/lib/ext/sunpkcs11.jar,/opt/jdk/jdk1.8.0-b87/jre/lib/ext/zipfs.jar,/opt/jdk/jdk1.8.0-b87/jre/lib/ext/cldrdata.jar,/w/jjg/work/tl/langtools/build/diag-examples/classes,/w/jjg/work/tl/langtools/dist/lib/javac.jar] [loading ZipFileIndexFileObject[/opt/jdk/jdk1.8.0-b87/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Object.class)]] [checking Verbose] [loading ZipFileIndexFileObject[/opt/jdk/jdk1.8.0-b87/lib/ct.sym(META-INF/sym/rt.jar/java/lang/AutoCloseable.class)]] [wrote RegularFileObject[/tmp/RunExamples2271864106063728804/classes/Verbose.class]] [total 4ms]

VerboseResolveMulti.java

Copyright, Info

class VerboseResolveMulti { void m() {} { m(); } }

Output:

examples/VerboseResolveMulti.java:32: Note: resolving method m in type VerboseResolveMulti to candidate 0 { m(); } ^ phase: BASIC with actuals: no arguments with type-args: no arguments candidates: #0 applicable method found: m()

VerboseResolveMulti1.java

Copyright, Info

class VerboseResolveMulti1 { void m(int i) {} { m(""); } }

Output:

examples/VerboseResolveMulti1.java:35: Note: erroneous resolution for method m in type VerboseResolveMulti1 { m(""); } ^ phase: BASIC with actuals: String with type-args: no arguments candidates: #0 not applicable method found: m(int) (argument mismatch; String cannot be converted to int) examples/VerboseResolveMulti1.java:35: Note: erroneous resolution for method m in type VerboseResolveMulti1 { m(""); } ^ phase: BOX with actuals: String with type-args: no arguments candidates: #0 not applicable method found: m(int) (argument mismatch; String cannot be converted to int) examples/VerboseResolveMulti1.java:35: Note: erroneous resolution for method m in type VerboseResolveMulti1 { m(""); } ^ phase: VARARITY with actuals: String with type-args: no arguments candidates: examples/VerboseResolveMulti1.java:35: error: incompatible types: String cannot be converted to int { m(""); } ^ Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 1 error

VoidNotAllowed.java

Copyright, Info

class X { void m() { } void m2() { System.err.println(m()); } }

Output:

examples/VoidNotAllowed.java:30: error: 'void' type not allowed here System.err.println(m()); ^ 1 error

WarnForwardRef.java

Copyright, Info

class X { static int x = X.y; static int y; }

Output:

examples/WarnForwardRef.java:28: warning: reference to variable 'y' before it has been initialized static int x = X.y; ^ 1 warning

WarnProcMessager

WarnProcMessager.java
Copyright, Info

class WarnProcMessager { }

processors/AnnoProc.java
Copyright

import java.util.*; import javax.annotation.processing.*; import javax.lang.model.*; import javax.lang.model.element.*; import javax.tools.*; @SupportedAnnotationTypes("*") public class AnnoProc extends AbstractProcessor { public boolean process(Set<? extends TypeElement> elems, RoundEnvironment renv) { if (renv.processingOver()) { Messager m = processingEnv.getMessager(); m.printMessage(Diagnostic.Kind.WARNING, "Warning!"); } return true; } public SourceVersion getSupportedSourceVersion() { return SourceVersion.latest(); } }

Output:

warning: Warning! 1 warning

WarnSelfRef.java

Copyright, Info

class X { static int x = X.x; }

Output:

examples/WarnSelfRef.java:28: warning: self-reference in initializer of variable 'x' static int x = X.x; ^ 1 warning

WarnSyntheticNameConflict.java

Copyright, Info

class WarnSyntheticNameConflict { static class Outer { WarnSyntheticNameConflict this$0 = null; } public class Inner extends Outer { } }

Output:

examples/WarnSyntheticNameConflict.java:33: warning: the symbol this$0 conflicts with a compiler-synthesized symbol in Outer public class Inner extends Outer { } ^ 1 warning

WarningAndWerror.java

Copyright, Info

import java.util.*; class X { List l; }

Output:

examples/WarningAndWerror.java:31: warning: [rawtypes] found raw type: List List l; ^ missing type arguments for generic class List<E> where E is a type-variable: E extends Object declared in interface List error: warnings found and -Werror specified 1 error 1 warning

WhereCaptured.java

Copyright, Info

import java.util.*; class WhereCaptured { <T> void m(List<T> l1, List<T> l2) {} void test(List<? super WhereCaptured> list) { m(list, list); } }

Output:

examples/WhereCaptured.java:40: error: method m in class WhereCaptured cannot be applied to given types; m(list, list); ^ required: List<T>,List<T> found: List<CAP#1>,List<CAP#2> reason: inferred type does not conform to equality constraint(s) inferred: CAP#2 equality constraints(s): CAP#2,CAP#1 where T is a type-variable: T extends Object declared in method <T>m(List<T>,List<T>) where CAP#1,CAP#2 are fresh type-variables: CAP#1 extends Object super: WhereCaptured from capture of ? super WhereCaptured CAP#2 extends Object super: WhereCaptured from capture of ? super WhereCaptured 1 error

WhereCaptured1.java

Copyright, Info

import java.util.*; class WhereCaptured { <T> void m(List<T> l1, List<T> l2) {} void test(List<? extends WhereCaptured> list) { m(list, list); } }

Output:

examples/WhereCaptured1.java:41: error: method m in class WhereCaptured cannot be applied to given types; m(list, list); ^ required: List<T>,List<T> found: List<CAP#1>,List<CAP#2> reason: inferred type does not conform to equality constraint(s) inferred: CAP#2 equality constraints(s): CAP#2,CAP#1 where T is a type-variable: T extends Object declared in method <T>m(List<T>,List<T>) where CAP#1,CAP#2 are fresh type-variables: CAP#1 extends WhereCaptured from capture of ? extends WhereCaptured CAP#2 extends WhereCaptured from capture of ? extends WhereCaptured 1 error

WhereFreshTvar.java

Copyright, Info

import java.util.*; class WhereFreshTvar { <T extends List<T>> T m() {} { Object o = (List<String>)m(); } }

Output:

examples/WhereFreshTvar.java:36: error: incompatible types: T cannot be converted to List<String> { Object o = (List<String>)m(); } ^ where T is a type-variable: T extends List<T> 1 error

WhereIntersection.java

Copyright, Info

class WhereIntersection { interface I1 {} interface I2 {} class A implements I1, I2 {} class B implements I1, I2 {} class Test { <Z> Z m(Z z1, Z z2) { return null; } void main(){ A a = m(new A(), new B()); } } }

Output:

examples/WhereIntersection.java:40: error: incompatible types: inferred type does not conform to upper bound(s) A a = m(new A(), new B()); ^ inferred: INT#1 upper bound(s): WhereIntersection.A,Object where INT#1 is an intersection type: INT#1 extends Object,I1,I2 1 error

WhereTypeVar.java

Copyright, Info

class WhereTypeVar<T extends String> { <T extends Integer> void test(T t) { m(t); } void m(T t) {} }

Output:

examples/WhereTypeVar.java:35: error: incompatible types: T#1 cannot be converted to T#2 m(t); ^ where T#1,T#2 are type-variables: T#1 extends Integer declared in method <T#1>test(T#1) T#2 extends String declared in class WhereTypeVar Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output 1 error

WrongNumberTypeArgs.java

Copyright, Info

import java.util.*; class T { List<Integer,String> list; }

Output:

examples/WrongNumberTypeArgs.java:29: error: wrong number of type arguments; required 1 List<Integer,String> list; ^ 1 error