@Override public IBuffer getBuffer() throws JavaModelException { IStatus status = validateClassFile(); if (status.isOK()) { return super.getBuffer(); } else { switch (status.getCode()) { case IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH: // don't throw a JavaModelException to be able to open .class file outside the classpath (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=138507 ) case IJavaModelStatusConstants.INVALID_ELEMENT_TYPES: // don't throw a JavaModelException to be able to open .class file in proj==src case without source (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=221904 ) return null; default: throw new JavaModelException(status); } } } /**
@Override public IBuffer getBuffer() throws JavaModelException { IStatus status = validateClassFile(); if (status.isOK()) { return super.getBuffer(); } else { switch (status.getCode()) { case IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH: // don't throw a JavaModelException to be able to open .class file outside the classpath (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=138507 ) case IJavaModelStatusConstants.INVALID_ELEMENT_TYPES: // don't throw a JavaModelException to be able to open .class file in proj==src case without source (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=221904 ) return null; default: throw new JavaModelException(status); } } } /**
@Override protected IStatus validateExistence(IResource underlyingResource) { // check whether the class file can be opened IStatus status = validateClassFile(); if (!status.isOK()) return status; if (underlyingResource != null) { if (!underlyingResource.isAccessible()) return newDoesNotExistStatus(); PackageFragmentRoot root; if ((underlyingResource instanceof IFolder) && (root = getPackageFragmentRoot()).isArchive()) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=204652 return root.newDoesNotExistStatus(); } } return JavaModelStatus.VERIFIED_OK; }
@Override protected IStatus validateExistence(IResource underlyingResource) { // check whether the class file can be opened IStatus status = validateClassFile(); if (!status.isOK()) return status; if (underlyingResource != null) { if (!underlyingResource.isAccessible()) return newDoesNotExistStatus(); PackageFragmentRoot root; if ((underlyingResource instanceof IFolder) && (root = getPackageFragmentRoot()).isArchive()) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=204652 return root.newDoesNotExistStatus(); } } return JavaModelStatus.VERIFIED_OK; }