diff options
author | Leo Ufimtsev | 2018-05-16 20:37:47 +0000 |
---|---|---|
committer | Leo Ufimtsev | 2018-05-16 21:10:26 +0000 |
commit | d451e52002aeb6e27e59809d60ef18043a768b70 (patch) | |
tree | 6746f189b6761a6312feda5305ba2524924f45b9 /bundles/org.eclipse.swt.tools/JNI Generation/org | |
parent | 9d334185fde44514da763f3766f9c872d149ab51 (diff) | |
download | eclipse.platform.swt-d451e52002aeb6e27e59809d60ef18043a768b70.tar.gz eclipse.platform.swt-d451e52002aeb6e27e59809d60ef18043a768b70.tar.xz eclipse.platform.swt-d451e52002aeb6e27e59809d60ef18043a768b70.zip |
Bug 534783 – SWT tools isn't rebuilding natives after foreach patch
Revert "For each conversion in swt.tools."
This reverts commit 9a92da14a27e579409c00ff3eefd197eac4209da.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=534783
Change-Id: I464b41bdc9bdd125b1f56b501e226fb89ceca310
Signed-off-by: Leo Ufimtsev <lufimtse@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.swt.tools/JNI Generation/org')
19 files changed, 129 insertions, 77 deletions
diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTClass.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTClass.java index e54221e232..a642b92ed9 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTClass.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTClass.java @@ -37,8 +37,8 @@ public class ASTClass extends ASTItem implements JNIClass { if (file.exists()) { return file.getAbsolutePath(); } - for (String import1 : imports) { - file = new File(basePath + import1.replace('.', '/') + "/" + simpleName + ".java"); + for (int i = 0; i < imports.length; i++) { + file = new File(basePath + imports[i].replace('.', '/') + "/" + simpleName + ".java"); if (file.exists()) { return file.getAbsolutePath(); } @@ -53,10 +53,10 @@ public class ASTClass extends ASTItem implements JNIClass { if (file.exists()) { return packageName + "." + simpleName; } - for (String import1 : imports) { - file = new File(basePath + import1.replace('.', '/') + "/" + simpleName + ".java"); + for (int i = 0; i < imports.length; i++) { + file = new File(basePath + imports[i].replace('.', '/') + "/" + simpleName + ".java"); if (file.exists()) { - return import1 + "." + simpleName; + return imports[i] + "." + simpleName; } } return simpleName; @@ -99,7 +99,8 @@ public ASTClass(String sourcePath, MetaData metaData) { FieldDeclaration[] fields = type.getFields(); List<ASTField> fid = new ArrayList<>(); - for (FieldDeclaration field : fields) { + for (int i = 0; i < fields.length; i++) { + FieldDeclaration field = fields[i]; List<VariableDeclarationFragment> fragments = field.fragments(); for (VariableDeclarationFragment fragment : fragments) { fid.add(new ASTField(this, source, field, fragment)); @@ -108,9 +109,9 @@ public ASTClass(String sourcePath, MetaData metaData) { this.fields = fid.toArray(new ASTField[fid.size()]); MethodDeclaration[] methods = type.getMethods(); List<ASTMethod> mid = new ArrayList<>(); - for (MethodDeclaration method : methods) { - if (method.getReturnType2() == null) continue; - mid.add(new ASTMethod(this, source, method)); + for (int i = 0; i < methods.length; i++) { + if (methods[i].getReturnType2() == null) continue; + mid.add(new ASTMethod(this, source, methods[i])); } this.methods = mid.toArray(new ASTMethod[mid.size()]); } diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTField.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTField.java index 4427e75731..1f490d200c 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTField.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTField.java @@ -100,7 +100,7 @@ public String getAccessor() { @Override public String getCast() { String cast = ((String)getParam("cast")).trim(); - if (!cast.isEmpty()) { + if (cast.length() > 0) { if (!cast.startsWith("(")) cast = "(" + cast; if (!cast.endsWith(")")) cast = cast + ")"; } diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTMethod.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTMethod.java index c251dc5745..a8cd8ce367 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTMethod.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ASTMethod.java @@ -64,7 +64,8 @@ public ASTMethod(ASTClass declaringClass, String source, MethodDeclaration metho paramTypes64 = new ASTType[parameters.size()]; this.parameters = new ASTParameter[paramTypes.length]; int i = 0; - for (SingleVariableDeclaration param : parameters) { + for (Iterator<SingleVariableDeclaration> iterator = parameters.iterator(); iterator.hasNext(); i++) { + SingleVariableDeclaration param = iterator.next(); paramTypes[i] = new ASTType(declaringClass.resolver, param.getType(), param.getExtraDimensions()); paramTypes64[i] = paramTypes[i]; this.parameters[i] = new ASTParameter(this, i, param.getName().getIdentifier()); @@ -115,7 +116,8 @@ public boolean isNativeUnique() { boolean result = true; String name = getName(); JNIMethod[] methods = declaringClass.getDeclaredMethods(); - for (JNIMethod mth : methods) { + for (int i = 0; i < methods.length; i++) { + JNIMethod mth = methods[i]; if ((mth.getModifiers() & Modifier.NATIVE) != 0 && this != mth && !this.equals(mth) && name.equals(mth.getName())) diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/AbstractItem.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/AbstractItem.java index bf40e0064d..181d347b4d 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/AbstractItem.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/AbstractItem.java @@ -31,7 +31,8 @@ public String flatten() { Set<String> set = params.keySet(); String[] keys = set.toArray(new String[set.size()]); Arrays.sort(keys); - for (String key : keys) { + for (int j = 0; j < keys.length; j++) { + String key = keys[j]; Object value = params.get(key); String valueStr = ""; if (value instanceof String) { @@ -76,8 +77,8 @@ public String[] getFlags() { @Override public boolean getFlag(String flag) { String[] flags = getFlags(); - for (String flag2 : flags) { - if (flag2.equals(flag)) return true; + for (int i = 0; i < flags.length; i++) { + if (flags[i].equals(flag)) return true; } return false; } diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupClass.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupClass.java index fa768cdcf1..8f4cc1c977 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupClass.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupClass.java @@ -99,7 +99,8 @@ void loadDirectory(File file) { if (entries == null) { entries = new String[0]; } - for (String entry : entries) { + for (int i = 0; i < entries.length; i++) { + String entry = entries[i]; File f = new File(file, entry); if (!f.isDirectory()) { if (f.getAbsolutePath().endsWith(".java")) { diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupConstants.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupConstants.java index d0192c7b14..69b58d0608 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupConstants.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupConstants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2018 IBM Corporation and others. + * Copyright (c) 2004, 2017 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 @@ -40,7 +40,8 @@ public void generate(JNIClass clazz) { public void generate(JNIField[] fields) { sort(fields); - for (JNIField field : fields) { + for (int i = 0; i < fields.length; i++) { + JNIField field = fields[i]; if ((field.getModifiers() & Modifier.FINAL) == 0) continue; generate(field); } diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupNatives.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupNatives.java index 293f759c9f..db66465645 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupNatives.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/CleanupNatives.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2018 IBM Corporation and others. + * Copyright (c) 2004, 2017 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 @@ -29,7 +29,8 @@ public void generate(JNIClass clazz) { public void generate(JNIMethod[] methods) { sort(methods); - for (JNIMethod method : methods) { + for (int i = 0; i < methods.length; i++) { + JNIMethod method = methods[i]; if ((method.getModifiers() & Modifier.NATIVE) == 0) continue; generate(method); } diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ConstantsGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ConstantsGenerator.java index 385371f676..8bce4db357 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ConstantsGenerator.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ConstantsGenerator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2018 IBM Corporation and others. + * Copyright (c) 2004, 2013 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 @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.swt.tools.internal; -import java.lang.reflect.*; +import java.lang.reflect.Modifier; public class ConstantsGenerator extends JNIGenerator { @@ -23,7 +23,8 @@ public void generate(JNIClass clazz) { public void generate(JNIField[] fields) { sort(fields); outputln("int main() {"); - for (JNIField field : fields) { + for (int i = 0; i < fields.length; i++) { + JNIField field = fields[i]; if ((field.getModifiers() & Modifier.FINAL) == 0) continue; generate(field); } @@ -51,7 +52,8 @@ public static void main(String[] args) { } try { ConstantsGenerator gen = new ConstantsGenerator(); - for (String clazzName : args) { + for (int i = 0; i < args.length; i++) { + String clazzName = args[i]; Class<?> clazz = Class.forName(clazzName); gen.generate(new ReflectClass(clazz)); } diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/EmbedMetaData.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/EmbedMetaData.java index 23694e775c..1c457c13ef 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/EmbedMetaData.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/EmbedMetaData.java @@ -49,7 +49,8 @@ public void generate(JNIClass clazz) { } public void generate(JNIField[] fields) { - for (JNIField field : fields) { + for (int i = 0; i < fields.length; i++) { + JNIField field = fields[i]; int mods = field.getModifiers(); if ((mods & Modifier.PUBLIC) == 0) continue; if ((mods & Modifier.FINAL) != 0) continue; @@ -69,7 +70,8 @@ public void generate(JNIField field) { } public void generate(JNIMethod[] methods) { - for (JNIMethod method : methods) { + for (int i = 0; i < methods.length; i++) { + JNIMethod method = methods[i]; if ((method.getModifiers() & Modifier.NATIVE) == 0) continue; generate(method); } diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGenerator.java index 83557aabbe..110167a12d 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGenerator.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGenerator.java @@ -131,7 +131,8 @@ static String getFunctionName(JNIMethod method, JNIType[] paramTypes) { StringBuilder buffer = new StringBuilder(); buffer.append(function); buffer.append("__"); - for (JNIType paramType : paramTypes) { + for (int i = 0; i < paramTypes.length; i++) { + JNIType paramType = paramTypes[i]; buffer.append(toC(paramType.getTypeSignature(false))); } return buffer.toString(); @@ -216,7 +217,8 @@ public void generate() { generateAutoGenNote(); generateIncludes(); sort(classes); - for (JNIClass clazz : classes) { + for (int i = 0; i < classes.length; i++) { + JNIClass clazz = classes[i]; if (getGenerate(clazz)) generate(clazz); if (progress != null) progress.step(); } @@ -236,7 +238,8 @@ public JNIClass[] getClasses() { } public boolean getCPP() { - for (JNIClass clazz : classes) { + for (int i = 0; i < classes.length; i++) { + JNIClass clazz = classes[i]; if (clazz.getFlag(FLAG_CPP)) { return true; } @@ -269,7 +272,8 @@ public String getOutputName() { } public boolean getM() { - for (JNIClass clazz : classes) { + for (int i = 0; i < classes.length; i++) { + JNIClass clazz = classes[i]; if (clazz.getFlag(FLAG_M)) { return true; } diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java index 6125715888..8a9ed8723d 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorApp.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2018 IBM Corporation and others. + * Copyright (c) 2004, 2017 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 @@ -226,9 +226,11 @@ public void generate(ProgressMonitor progress) { this.progress = progress; if (progress != null) { int nativeCount = 0; - for (JNIClass clazz : natives) { + for (int i = 0; i < natives.length; i++) { + JNIClass clazz = natives[i]; JNIMethod[] methods = clazz.getDeclaredMethods(); - for (JNIMethod method : methods) { + for (int j = 0; j < methods.length; j++) { + JNIMethod method = methods[j]; if ((method.getModifiers() & Modifier.NATIVE) == 0) continue; nativeCount++; } @@ -297,7 +299,8 @@ String[] getClassNames() { if(entries == null) { entries = new String[0]; } - for (String entry : entries) { + for (int i = 0; i < entries.length; i++) { + String entry = entries[i]; File f = new File(file, entry); if (!f.isDirectory()) { if (f.getAbsolutePath().endsWith(".class")) { @@ -351,7 +354,8 @@ JNIClass[] getASTClasses() { if (files == null) { files = new File[0]; } - for (File file : files) { + for (int i = 0; i < files.length; i++) { + File file = files[i]; try { String path = file.getAbsolutePath().replace('\\', '/'); if (path.endsWith(".java")) { @@ -377,9 +381,11 @@ JNIClass[] getASTClasses() { public JNIClass[] getNativesClasses(JNIClass[] classes) { if (mainClass == null) return new JNIClass[0]; List<JNIClass> result = new ArrayList<>(); - for (JNIClass clazz : classes) { + for (int i = 0; i < classes.length; i++) { + JNIClass clazz = classes[i]; JNIMethod[] methods = clazz.getDeclaredMethods(); - for (JNIMethod method : methods) { + for (int j = 0; j < methods.length; j++) { + JNIMethod method = methods[j]; int mods = method.getModifiers(); if ((mods & Modifier.NATIVE) != 0) { result.add(clazz); @@ -404,7 +410,8 @@ public JNIClass[] getStructureClasses(JNIClass[] classes) { } JNIField[] fields = clazz.getDeclaredFields(); boolean hasPublicFields = false; - for (JNIField field : fields) { + for (int j = 0; j < fields.length; j++) { + JNIField field = fields[j]; int mods = field.getModifiers(); if ((mods & Modifier.PUBLIC) != 0 && (mods & Modifier.STATIC) == 0) { hasPublicFields = true; diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorAppUI.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorAppUI.java index 21274bd229..7a0834b38b 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorAppUI.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/JNIGeneratorAppUI.java @@ -152,7 +152,8 @@ void generateAll() { shell.setCursor(cursor); shell.setEnabled(false); Control[] children = actionsPanel.getChildren(); - for (Control child : children) { + for (int i = 0; i < children.length; i++) { + Control child = children[i]; if (child instanceof Button) child.setEnabled(false); } boolean showProgress = true; @@ -200,7 +201,8 @@ void generateAll() { while (!done[0]) { if (!display.readAndDispatch()) display.sleep(); } - for (Control child : children) { + for (int i = 0; i < children.length; i++) { + Control child = children[i]; if (child instanceof Button) child.setEnabled(true); } if (showProgress) { @@ -238,7 +240,8 @@ JNIMethod[] getSelectedMethods() { TableItem[] selection = membersLt.getSelection(); JNIMethod[] methods = new JNIMethod[selection.length]; int count = 0; - for (TableItem item : selection) { + for (int i = 0; i < selection.length; i++) { + TableItem item = selection [i]; Object data = item.getData(); if (data instanceof JNIMethod) { methods[count++] = (JNIMethod)data; @@ -256,7 +259,8 @@ JNIField[] getSelectedFields() { TableItem[] selection = membersLt.getSelection(); JNIField[] fields = new JNIField[selection.length]; int count = 0; - for (TableItem item : selection) { + for (int i = 0; i < selection.length; i++) { + TableItem item = selection [i]; Object data = item.getData(); if (data instanceof JNIField) { fields[count++] = (JNIField)data; @@ -911,7 +915,8 @@ String getClassString(JNIType type) { String getFlagsString(String[] flags) { if (flags.length == 0) return ""; StringBuilder buffer = new StringBuilder(); - for (String flag : flags) { + for (int j = 0; j < flags.length; j++) { + String flag = flags[j]; if (buffer.length() != 0) buffer.append(", "); buffer.append(flag); } @@ -953,7 +958,8 @@ void updateClasses() { item.setChecked(clazz.getGenerate()); } TableColumn[] columns = classesLt.getColumns(); - for (TableColumn column : columns) { + for (int i = 0; i < columns.length; i++) { + TableColumn column = columns[i]; column.pack(); } classesLt.setSelection(mainIndex); @@ -963,7 +969,8 @@ void updateMembers() { membersLt.removeAll(); membersLt.setHeaderVisible(false); TableColumn[] columns = membersLt.getColumns(); - for (TableColumn column : columns) { + for (int i = 0; i < columns.length; i++) { + TableColumn column = columns[i]; column.dispose(); } int[] indices = classesLt.getSelectionIndices(); @@ -972,7 +979,8 @@ void updateMembers() { JNIClass clazz = (JNIClass)classItem.getData(); boolean hasNatives = false; JNIMethod[] methods = clazz.getDeclaredMethods(); - for (JNIMethod method : methods) { + for (int i = 0; i < methods.length; i++) { + JNIMethod method = methods[i]; int mods = method.getModifiers(); if (hasNatives =((mods & Modifier.NATIVE) != 0)) break; } @@ -990,7 +998,8 @@ void updateMembers() { column.setText("Exclude"); */ JNIGenerator.sort(methods); - for (JNIMethod method : methods) { + for (int i = 0; i < methods.length; i++) { + JNIMethod method = methods[i]; if ((method.getModifiers() & Modifier.NATIVE) == 0) continue; TableItem item = new TableItem(membersLt, SWT.NONE); item.setData(method); @@ -1017,7 +1026,8 @@ void updateMembers() { column.setText("Exclude"); */ JNIField[] fields = clazz.getDeclaredFields(); - for (JNIField field : fields) { + for (int i = 0; i < fields.length; i++) { + JNIField field = fields[i]; int mods = field.getModifiers(); if (((mods & Modifier.PUBLIC) == 0) || ((mods & Modifier.FINAL) != 0) || @@ -1035,7 +1045,8 @@ void updateMembers() { } } columns = membersLt.getColumns(); - for (TableColumn column : columns) { + for (int i = 0; i < columns.length; i++) { + TableColumn column = columns[i]; column.pack(); } membersLt.setHeaderVisible(true); @@ -1065,7 +1076,8 @@ void updateParameters() { item.setText(PARAM_FLAGS_COLUMN, getFlagsString(param.getFlags())); } TableColumn[] columns = paramsLt.getColumns(); - for (TableColumn column : columns) { + for (int i = 0; i < columns.length; i++) { + TableColumn column = columns[i]; column.pack(); } paramsLt.setRedraw(true); diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/MetaDataGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/MetaDataGenerator.java index 284516f41c..44f58a34d1 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/MetaDataGenerator.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/MetaDataGenerator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2018 IBM Corporation and others. + * Copyright (c) 2004, 2017 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 @@ -33,7 +33,8 @@ public void generate(JNIClass clazz) { } public void generate(JNIField[] fields) { - for (JNIField field : fields) { + for (int i = 0; i < fields.length; i++) { + JNIField field = fields[i]; int mods = field.getModifiers(); if ((mods & Modifier.PUBLIC) == 0) continue; if ((mods & Modifier.FINAL) != 0) continue; @@ -53,7 +54,8 @@ public void generate(JNIField field) { public void generate(JNIMethod[] methods) { sort(methods); - for (JNIMethod method : methods) { + for (int i = 0; i < methods.length; i++) { + JNIMethod method = methods[i]; if ((method.getModifiers() & Modifier.NATIVE) == 0) continue; generate(method); outputln(); diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/NativesGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/NativesGenerator.java index c8583e58b5..f4ae947c36 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/NativesGenerator.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/NativesGenerator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2018 IBM Corporation and others. + * Copyright (c) 2004, 2017 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 @@ -72,7 +72,8 @@ public void generate(JNIClass clazz) { public void generate(JNIMethod[] methods) { sort(methods); - for (JNIMethod method : methods) { + for (int i = 0; i < methods.length; i++) { + JNIMethod method = methods[i]; if ((method.getModifiers() & Modifier.NATIVE) == 0) continue; generate(method); if (progress != null) progress.step(); @@ -222,7 +223,8 @@ public void setEnterExitMacro(boolean enterExitMacro) { void generateExcludes(JNIMethod[] methods) { HashSet<String> excludes = new HashSet<>(); - for (JNIMethod method : methods) { + for (int i = 0; i < methods.length; i++) { + JNIMethod method = methods[i]; if ((method.getModifiers() & Modifier.NATIVE) == 0) continue; String exclude = method.getExclude(); if (exclude.length() != 0) { @@ -231,7 +233,8 @@ void generateExcludes(JNIMethod[] methods) { } for (String exclude: excludes) { outputln(exclude); - for (JNIMethod method : methods) { + for (int i = 0; i < methods.length; i++) { + JNIMethod method = methods[i]; if ((method.getModifiers() & Modifier.NATIVE) == 0) continue; String methodExclude = method.getExclude(); if (exclude.equals(methodExclude)) { @@ -520,7 +523,8 @@ boolean generateLocalVars(JNIParameter[] params, JNIType returnType, JNIType ret boolean generateGetters(JNIMethod method, JNIParameter[] params) { boolean genFailTag = false; int criticalCount = 0; - for (JNIParameter param : params) { + for (int i = 0; i < params.length; i++) { + JNIParameter param = params[i]; if (!isCritical(param)) { genFailTag |= generateGetParameter(method, param, false, 1); } else { @@ -528,7 +532,8 @@ boolean generateGetters(JNIMethod method, JNIParameter[] params) { } } if (criticalCount != 0) { - for (JNIParameter param : params) { + for (int i = 0; i < params.length; i++) { + JNIParameter param = params[i]; if (isCritical(param)) { genFailTag |= generateGetParameter(method, param, true, 2); } diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectField.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectField.java index da668963e0..6cc20a87f1 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectField.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectField.java @@ -97,7 +97,7 @@ public String getAccessor() { @Override public String getCast() { String cast = ((String)getParam("cast")).trim(); - if (!cast.isEmpty()) { + if (cast.length() > 0) { if (!cast.startsWith("(")) cast = "(" + cast; if (!cast.endsWith(")")) cast = cast + ")"; } diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectMethod.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectMethod.java index e8a68ed299..aef0caf4c9 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectMethod.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/ReflectMethod.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2018 IBM Corporation and others. + * Copyright (c) 2004, 2015 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 @@ -128,7 +128,8 @@ public boolean isNativeUnique() { boolean result = true; String name = getName(); JNIMethod[] methods = declaringClass.getDeclaredMethods(); - for (JNIMethod mth : methods) { + for (int i = 0; i < methods.length; i++) { + JNIMethod mth = methods[i]; if ((mth.getModifiers() & Modifier.NATIVE) != 0 && this != mth && !this.equals(mth) && name.equals(mth.getName())) diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/SizeofGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/SizeofGenerator.java index a56ea3f517..872a31c0c9 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/SizeofGenerator.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/SizeofGenerator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2018 IBM Corporation and others. + * Copyright (c) 2004, 2013 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 @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.swt.tools.internal; -import java.lang.reflect.*; +import java.lang.reflect.Modifier; public class SizeofGenerator extends JNIGenerator { @@ -36,7 +36,8 @@ public void generate() { public void generate(JNIField[] fields) { sort(fields); - for (JNIField field : fields) { + for (int i = 0; i < fields.length; i++) { + JNIField field = fields[i]; if ((field.getModifiers() & Modifier.FINAL) == 0) continue; generate(field); } @@ -57,7 +58,8 @@ public static void main(String[] args) { } try { SizeofGenerator gen = new SizeofGenerator(); - for (String clazzName : args) { + for (int i = 0; i < args.length; i++) { + String clazzName = args[i]; Class<?> clazz = Class.forName(clazzName); gen.generate(new ReflectClass(clazz)); } diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StatsGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StatsGenerator.java index 8ccab69987..f6d766bb49 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StatsGenerator.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StatsGenerator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2018 IBM Corporation and others. + * Copyright (c) 2004, 2013 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 @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.swt.tools.internal; -import java.lang.reflect.*; +import java.lang.reflect.Modifier; public class StatsGenerator extends JNIGenerator { @@ -110,7 +110,8 @@ void generateSourceFile(JNIClass clazz) { output(className); outputln("_nativeFunctionNames[] = {"); sort(methods); - for (JNIMethod method : methods) { + for (int i = 0; i < methods.length; i++) { + JNIMethod method = methods[i]; if ((method.getModifiers() & Modifier.NATIVE) == 0) continue; String function = getFunctionName(method), function64 = getFunctionName(method, method.getParameterTypes64()); if (!function.equals(function64)) { @@ -192,7 +193,8 @@ void generateStatsNatives(String className) { void generateFunctionEnum(JNIMethod[] methods) { if (methods.length == 0) return; outputln("typedef enum {"); - for (JNIMethod method : methods) { + for (int i = 0; i < methods.length; i++) { + JNIMethod method = methods[i]; if ((method.getModifiers() & Modifier.NATIVE) == 0) continue; String function = getFunctionName(method), function64 = getFunctionName(method, method.getParameterTypes64()); if (!function.equals(function64)) { diff --git a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StructsGenerator.java b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StructsGenerator.java index f58d9c9e77..bc8d30c6cd 100644 --- a/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StructsGenerator.java +++ b/bundles/org.eclipse.swt.tools/JNI Generation/org/eclipse/swt/tools/internal/StructsGenerator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2018 IBM Corporation and others. + * Copyright (c) 2004, 2017 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 @@ -80,7 +80,8 @@ public String getSuffix() { void generateExcludes(JNIClass[] classes) { HashSet<String> excludes = new HashSet<>(); - for (JNIClass clazz : classes) { + for (int i = 0; i < classes.length; i++) { + JNIClass clazz = classes[i]; String exclude = clazz.getExclude(); if (exclude.length() != 0) { excludes.add(exclude); @@ -88,7 +89,8 @@ void generateExcludes(JNIClass[] classes) { } for (String exclude : excludes) { outputln(exclude); - for (JNIClass clazz : classes) { + for (int i = 0; i < classes.length; i++) { + JNIClass clazz = classes[i]; String classExclude = clazz.getExclude(); if (exclude.equals(classExclude)) { output("#define NO_"); @@ -199,7 +201,8 @@ void generateFIDsStructure(JNIClass clazz) { output("\tjfieldID "); JNIField[] fields = clazz.getDeclaredFields(); boolean first = true; - for (JNIField field : fields) { + for (int i = 0; i < fields.length; i++) { + JNIField field = fields[i]; if (ignoreField(field)) continue; if (!first) output(", "); output(field.getName()); @@ -245,7 +248,8 @@ void generateCacheFunction(JNIClass clazz) { } outputln(); JNIField[] fields = clazz.getDeclaredFields(); - for (JNIField field : fields) { + for (int i = 0; i < fields.length; i++) { + JNIField field = fields[i]; if (ignoreField(field)) continue; output("\t"); output(clazzName); @@ -289,7 +293,8 @@ void generateGetFields(JNIClass clazz) { } } JNIField[] fields = clazz.getDeclaredFields(); - for (JNIField field : fields) { + for (int i = 0; i < fields.length; i++) { + JNIField field = fields[i]; if (ignoreField(field)) continue; String exclude = field.getExclude(); if (exclude.length() != 0) { @@ -442,7 +447,8 @@ void generateSetFields(JNIClass clazz) { } } JNIField[] fields = clazz.getDeclaredFields(); - for (JNIField field : fields) { + for (int i = 0; i < fields.length; i++) { + JNIField field = fields[i]; if (ignoreField(field)) continue; String exclude = field.getExclude(); if (exclude.length() != 0) { |