Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVikas Chandra2018-10-08 09:27:41 +0000
committerVikas Chandra2018-10-08 09:27:41 +0000
commit8b15d1d31875ffcbc1cde02fb112406b1b0f8e50 (patch)
tree997f76514458bd665caa2a219f007b3992b60e73
parent7b8e7a9061faed18bcfd16593f31c1f90fadafeb (diff)
downloadeclipse.pde.ui-BETA_JAVA11.tar.gz
eclipse.pde.ui-BETA_JAVA11.tar.xz
eclipse.pde.ui-BETA_JAVA11.zip
Bug 539598 - 281 API tools junit failures with I20180927-0135 with JavaY20181025-0530P20181010-0815P20181010-0735P20181008-0545BETA_JAVA11
11 Change-Id: Ife115211514fc83f908795b0dd92e35e48967292 Signed-off-by: Vikas Chandra <Vikas.Chandra@in.ibm.com>
-rw-r--r--apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/TypeStructureBuilder.java65
1 files changed, 63 insertions, 2 deletions
diff --git a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/TypeStructureBuilder.java b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/TypeStructureBuilder.java
index e9dc97c50b..275ef861d6 100644
--- a/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/TypeStructureBuilder.java
+++ b/apitools/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/model/TypeStructureBuilder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2017 IBM Corporation and others.
+ * Copyright (c) 2007, 2018 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
@@ -14,6 +14,8 @@ package org.eclipse.pde.api.tools.internal.model;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
+import java.util.Arrays;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
@@ -21,6 +23,11 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
+import org.eclipse.jdt.launching.AbstractVMInstall;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
+import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.api.tools.internal.model.StubArchiveApiTypeContainer.ArchiveApiTypeRoot;
import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin;
@@ -47,6 +54,22 @@ public class TypeStructureBuilder extends ClassVisitor {
/**
* Builds a type structure for a class file. Note that if an API component
* is not specified, then some operations on the resulting {@link IApiType}
+ * will not be available (navigating super types, member types, etc). This
+ * constructor uses ASM7_EXPERIMENTAL
+ *
+ * @param useExperimental
+ * @param cv class file visitor
+ * @param component originating API component or <code>null</code> if
+ * unknown
+ */
+ TypeStructureBuilder(boolean useExperimental, ClassVisitor cv, IApiComponent component, IApiTypeRoot file) {
+ super(Opcodes.ASM7_EXPERIMENTAL, cv);
+ fComponent = component;
+ fFile = file;
+ }
+ /**
+ * Builds a type structure for a class file. Note that if an API component
+ * is not specified, then some operations on the resulting {@link IApiType}
* will not be available (navigating super types, member types, etc).
*
* @param cv class file visitor
@@ -254,7 +277,45 @@ public class TypeStructureBuilder extends ClassVisitor {
* @return
*/
public static IApiType buildTypeStructure(byte[] bytes, IApiComponent component, IApiTypeRoot file) {
- TypeStructureBuilder visitor = new TypeStructureBuilder(new ClassNode(), component, file);
+ boolean useExperimental = false;
+ try {
+ String[] executionEnvironments = component.getExecutionEnvironments();
+ if (executionEnvironments.length == 1) {
+ String string = executionEnvironments[0];
+ IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
+ IExecutionEnvironment env = manager.getEnvironment(string);
+ IVMInstall[] compatibleVMs = env.getCompatibleVMs();
+ Arrays.sort(compatibleVMs, new Comparator<IVMInstall>() {
+ @Override
+ public int compare(IVMInstall o1, IVMInstall o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+ });
+ for (int i = 0; i < compatibleVMs.length; i++) {
+ if (compatibleVMs[i] instanceof AbstractVMInstall) {
+ AbstractVMInstall ivmInstall = (AbstractVMInstall) compatibleVMs[i];
+ String javaVersion = ivmInstall.getJavaVersion();
+ if (i == 0) {
+ useExperimental = javaVersion.equals("11"); //$NON-NLS-1$
+ }
+ boolean strictlyCompatible = env.isStrictlyCompatible(ivmInstall);
+ // if strictly compatible, then take that value
+ if (strictlyCompatible) {
+ useExperimental = javaVersion.equals("11"); //$NON-NLS-1$
+ break;
+ }
+ }
+ }
+ }
+
+ } catch (Exception e1) {
+ // do nothing
+ }
+ // Till ASM7 is incorporated, use ASM7_EXPERIMENTAL to
+ // avoidOperationUnsupportedException if Java 11 is on build path. If
+ // not Java
+ // 11 then use ASM6
+ TypeStructureBuilder visitor = useExperimental ? new TypeStructureBuilder(useExperimental, new ClassNode(), component, file) : new TypeStructureBuilder(new ClassNode(), component, file);
try {
ClassReader classReader = new ClassReader(bytes);
classReader.accept(visitor, ClassReader.SKIP_CODE | ClassReader.SKIP_FRAMES);

Back to the top