diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/TestVerifier.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/TestVerifier.java index 8c38c58..f72aa69 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/TestVerifier.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/TestVerifier.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -334,7 +334,7 @@ " this.socket.setTcpNoDelay(true);\n" + " server.close();\n" + "\n" + - " DataInputStream in = new DataInputStream(this.socket.getInputStream());\n" + + " final DataInputStream in = new DataInputStream(this.socket.getInputStream());\n" + " final DataOutputStream out = new DataOutputStream(this.socket.getOutputStream());\n" + " while (true) {\n" + " final String className = in.readUTF();\n" + @@ -354,7 +354,12 @@ " } catch (IOException e1) {\n" + " // ignore\n" + " }\n" + - " }\n" + + " } finally {\n" + + " try {\n" + + " in.close();\n" + + " out.close();\n" + + " } catch (IOException ioex) {}\n" + + " }\n" + " }\n" + " };\n" + " thread.start();\n" + diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java index 2bd50bc..115bf83 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeIds.java @@ -7,7 +7,9 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Stephan Herrmann - Contribution for bug 349326 - [1.7] new warning for missing try-with-resources + * Stephan Herrmann - Contributions for + * bug 349326 - [1.7] new warning for missing try-with-resources + * bug 359362 - FUP of bug 349326: Resource leak on non-Closeable resource *******************************************************************************/ package org.eclipse.jdt.internal.compiler.lookup; @@ -184,6 +186,11 @@ final int BOXING = 0x200; final int UNBOXING = 0x400; + /** + * Marks a type whose type bits have not yet been initialized. + * @see ReferenceBinding#hasTypeBit(int) + */ + final int BitUninitialized = 0x8000000; /** * Marks all sub-types of java.lang.AutoCloseable. * @see ReferenceBinding#hasTypeBit(int) diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java index e463960..995f30e 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java @@ -10,6 +10,7 @@ * Stephan Herrmann - Contributions for * bug 282152 - [1.5][compiler] Generics code rejected by Eclipse but accepted by javac * bug 349326 - [1.7] new warning for missing try-with-resources + * bug 359362 - FUP of bug 349326: Resource leak on non-Closeable resource *******************************************************************************/ package org.eclipse.jdt.internal.compiler.lookup; @@ -44,7 +45,7 @@ this.modifiers = ClassFileConstants.AccPublic | ExtraCompilerModifiers.AccGenericSignature; // treat type var as public this.tagBits |= TagBits.HasTypeVariable; this.environment = environment; - this.typeBits = -1; + this.typeBits = TypeIds.BitUninitialized; } /** @@ -311,14 +312,15 @@ } public boolean hasTypeBit(int bit) { - if (this.typeBits == -1) { + if (this.typeBits == TypeIds.BitUninitialized) { // initialize from bounds this.typeBits = 0; - if (this.superclass != null) + if (this.superclass != null && this.superclass.hasTypeBit(~TypeIds.BitUninitialized)) this.typeBits |= this.superclass.typeBits; if (this.superInterfaces != null) for (int i = 0, l = this.superInterfaces.length; i < l; i++) - this.typeBits |= this.superInterfaces[i].typeBits; + if (this.superInterfaces[i].hasTypeBit(~TypeIds.BitUninitialized)) + this.typeBits |= this.superInterfaces[i].typeBits; } return (this.typeBits & bit) != 0; } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java index 375ebec..01f369e 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/WildcardBinding.java @@ -7,7 +7,9 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Stephan Herrmann - Contribution for bug 349326 - [1.7] new warning for missing try-with-resources + * Stephan Herrmann - Contribution for + * bug 349326 - [1.7] new warning for missing try-with-resources + * bug 359362 - FUP of bug 349326: Resource leak on non-Closeable resource *******************************************************************************/ package org.eclipse.jdt.internal.compiler.lookup; @@ -55,7 +57,7 @@ if (bound instanceof UnresolvedReferenceBinding) ((UnresolvedReferenceBinding) bound).addWrapper(this, environment); this.tagBits |= TagBits.HasUnresolvedTypeVariables; // cleared in resolve() - this.typeBits = -1; + this.typeBits = TypeIds.BitUninitialized; } public int kind() { @@ -423,14 +425,15 @@ } public boolean hasTypeBit(int bit) { - if (this.typeBits == -1) { + if (this.typeBits == TypeIds.BitUninitialized) { // initialize from upper bounds this.typeBits = 0; - if (this.superclass != null) + if (this.superclass != null && this.superclass.hasTypeBit(~TypeIds.BitUninitialized)) this.typeBits |= this.superclass.typeBits; if (this.superInterfaces != null) for (int i = 0, l = this.superInterfaces.length; i < l; i++) - this.typeBits |= this.superInterfaces[i].typeBits; + if (this.superInterfaces[i].hasTypeBit(~TypeIds.BitUninitialized)) + this.typeBits |= this.superInterfaces[i].typeBits; } return (this.typeBits & bit) != 0; }