Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Vosburgh2013-07-03 21:54:56 +0000
committerBrian Vosburgh2013-07-03 21:59:15 +0000
commitbdb883a154abecc212006142fcdcebe01ab05946 (patch)
tree3ef87b72313d6606f51468d193ba47ed44900e9b
parent249e318f47bcd136caa55bf7b7fa751e3ebc5e21 (diff)
downloadwebtools.dali-bdb883a154abecc212006142fcdcebe01ab05946.tar.gz
webtools.dali-bdb883a154abecc212006142fcdcebe01ab05946.tar.xz
webtools.dali-bdb883a154abecc212006142fcdcebe01ab05946.zip
[397108] fix NPE in JAXB JavaElementAdapterFactory
-rw-r--r--jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JavaElementAdapterFactory.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/platform/JavaElementAdapterFactory.java2
2 files changed, 15 insertions, 3 deletions
diff --git a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JavaElementAdapterFactory.java b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JavaElementAdapterFactory.java
index 885627eaec..22d07b29a5 100644
--- a/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JavaElementAdapterFactory.java
+++ b/jaxb/plugins/org.eclipse.jpt.jaxb.core/src/org/eclipse/jpt/jaxb/core/internal/JavaElementAdapterFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
+ * Copyright (c) 2012, 2013 Oracle. 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 http://www.eclipse.org/legal/epl-v10.html.
@@ -9,8 +9,10 @@
******************************************************************************/
package org.eclipse.jpt.jaxb.core.internal;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformConfig;
/**
@@ -39,8 +41,18 @@ public class JavaElementAdapterFactory
private Object getAdapter(IJavaElement javaElement, Class<?> adapterType) {
if (adapterType == JaxbPlatformConfig.class) {
- return javaElement.getResource().getAdapter(JaxbPlatformConfig.class);
+ return this.getJaxbPlatformConfig(javaElement);
}
return null;
}
+
+ private Object getJaxbPlatformConfig(IJavaElement javaElement) {
+ IJavaProject javaProject = javaElement.getJavaProject();
+ if (javaProject == null) {
+ return null; // IJavaModel does not have an IJavaProject
+ }
+ IProject project = javaProject.getProject();
+ // not sure an IJavaProject can have no IProject...
+ return (project == null) ? null : project.getAdapter(JaxbPlatformConfig.class);
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/platform/JavaElementAdapterFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/platform/JavaElementAdapterFactory.java
index d3a2f5a265..a30d7abcd7 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/platform/JavaElementAdapterFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/platform/JavaElementAdapterFactory.java
@@ -49,7 +49,7 @@ public class JavaElementAdapterFactory
private Object getJpaPlatformConfig(IJavaElement javaElement) {
IJavaProject javaProject = javaElement.getJavaProject();
if (javaProject == null) {
- return null; // IJavaModel does not have an IProject
+ return null; // IJavaModel does not have an IJavaProject
}
IProject project = javaProject.getProject();
// not sure an IJavaProject can have no IProject...

Back to the top