Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified sources/net.sf.j2s.core/dist/dropins/net.sf.j2s.core.jar
Binary file not shown.
Binary file modified sources/net.sf.j2s.core/dist/net.sf.j2s.core_3.1.1.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
import org.eclipse.jdt.core.dom.WhileStatement;
import org.eclipse.jdt.core.dom.WildcardType;

// BH 3/27/2018 -- fix for anonymous inner classes of inner classes not having this.this$0
// BH 1/5/2018 -- @j2sKeep removed; refactored into one class

// BH 12/31/2017 -- competely rewritten for no run-time ambiguities
Expand Down Expand Up @@ -252,7 +253,7 @@ private void setInnerGlobals(Java2ScriptVisitor parent, ASTNode node, String vis
global_includes = parent.global_includes;
global_j2sFlag_isDebugging = parent.global_j2sFlag_isDebugging;
global_mapBlockJavadoc = parent.global_mapBlockJavadoc;
parentClassName = parent.getQualifiedClassName();
this$0Name = parent.getQualifiedClassName();

innerTypeNode = node;
setClassName(visitorClassName);
Expand Down Expand Up @@ -1076,7 +1077,7 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
// definition in the static buffer and return
String className;
if (parent instanceof TypeDeclarationStatement) {
String anonClassName = assureQualifiedNameAllowP$(binding.isAnonymous() || binding.isLocal()
String anonClassName = assureQualifiedNameAllowP$(isAnonymous|| binding.isLocal()
? binding.getBinaryName() : binding.getQualifiedName());
className = anonClassName.substring(anonClassName.lastIndexOf('.') + 1);
} else {
Expand All @@ -1089,6 +1090,7 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
tempVisitor = new Java2ScriptVisitor(); // Default visitor
}
tempVisitor.setInnerGlobals(this, node, className);

node.accept(tempVisitor);
trailingBuffer.append(tempVisitor.buffer.toString());
return false;
Expand Down Expand Up @@ -1130,11 +1132,14 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>

String oldClassName = null;
String fullClassName, defaultPackageName;

String this$0Name0 = this$0Name;
if (isAnonymous) {
oldClassName = typeAdapter.getClassName();
fullClassName = getAnonymousName(binding); // P$.Test_Enum$Planet$1
defaultPackageName = "null";
// anonymous classes reference their package, not their outer class in Clazz.newClass,
// so clazz.$this$0 is not assigned.
this$0Name = null;
} else {
fullClassName = getQualifiedClassName(); // test.Test_Enum.Planet
defaultPackageName = global_PackageName;
Expand Down Expand Up @@ -1468,6 +1473,7 @@ private boolean addClassOrInterface(ASTNode node, ITypeBinding binding, List<?>
if (isAnonymous) {
buffer.append(")");
typeAdapter.setClassName(oldClassName);
this$0Name = this$0Name0;
}
return false;
}
Expand Down Expand Up @@ -1838,7 +1844,7 @@ private static final String getPrimitiveTYPE(String name) {
private int blockLevel = 0;
private int currentBlockForVisit = -1;

public String parentClassName;
public String this$0Name;


/**
Expand Down Expand Up @@ -3542,7 +3548,7 @@ private void appendShortenedQualifiedName(String packageName, String name, boole
}

private String getSyntheticReference(String className) {
b$name = (className.equals(parentClassName) ? ".this$0" : ".b$['" + assureQualifiedNameNoC$(null, className) + "']");
b$name = (className.equals(this$0Name) ? ".this$0" : ".b$['" + assureQualifiedNameNoC$(null, className) + "']");
return "this" + b$name;
}

Expand Down

This file was deleted.

11 changes: 4 additions & 7 deletions sources/net.sf.j2s.java.core/src/swingjs/JSAudio.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import javax.sound.sampled.Line;
import javax.sound.sampled.UnsupportedAudioFileException;

import javajs.api.ResettableStream;
import javajs.util.BC;
import javajs.util.Base64;
import javajs.util.OC;
Expand Down Expand Up @@ -370,10 +369,9 @@ private static AudioFormat getAudioFormatForStreamOrBytes(

Map<String, Object> props = new Hashtable<String, Object>();
String fmt = (stream == null ? getAudioTypeForBytes(header) : getAudioTypeForStream(stream));
ResettableStream jsstream = (ResettableStream) stream;
props.put("fileFormat", fmt);
if (stream != null)
jsstream.resetStream();
stream.reset();
Encoding encoding = null;
float sampleRate = -1;
int sampleSizeInBits = -1;
Expand Down Expand Up @@ -423,23 +421,22 @@ private static AudioFormat getAudioFormatForStreamOrBytes(
} catch (Throwable e) {
} finally {
if (stream != null)
jsstream.resetStream();
stream.reset();
}
return new AudioFormat(encoding, sampleRate, sampleSizeInBits, channels,
frameSize, frameRate, bigEndian, props);
}


private static String getAudioTypeForStream(ByteArrayInputStream stream) throws UnsupportedAudioFileException {
ResettableStream jsstream = (ResettableStream) (Object) stream;
jsstream.resetStream();
stream.reset();
byte[] b = new byte[12];
try {
stream.read(b);
} catch (IOException e) {
// no problem
}
jsstream.resetStream();
stream.reset();
return getAudioTypeForBytes(b);
}

Expand Down